Uploaded by udesh ishanka

Programming Assignment Final

advertisement
Higher Nationals
Internal verification of assessment decisions – BTEC (RQF)
INTERNAL VERIFICATION – ASSESSMENT DECISIONS – Software Engineering
Programme title
Assessor
Unit(s)
Assignment title
Student’s name
Higher National Diploma in Computing – Software Engineering
Miss. Shifani Mohideen
Internal Verifier
Unit_01:PRO - Programming
Design &Implement a GUI based system using a suitable Integrated
Development Environment
Narayana Mudiyanselage Udesh Ishanka
List which assessment criteria
the Assessor has awarded.
Pass
Merit
Distinction
INTERNAL VERIFIER CHECKLIST
Do the assessment criteria awarded match
those shown in the assignment brief?
Is the Pass/Merit/Distinction grade awarded
justified by the assessor’s comments on the
student work?
Has the work been assessed
accurately?
Is the feedback to the student:
Give details:
• Constructive?
• Linked to relevant assessment criteria?
• Identifying opportunities for
improved performance?
• Agreeing actions?
Does the assessment decision need
amending?
Y/N
Y/N
Y/N
Y/N
Y/N
Y/N
Y/N
Y/N
Assessor signature
Date
Internal Verifier signature
Date
Programme Leader signature (if required)
Date
Confirm action completed
Remedial action taken
Give details:
Assessor signature
Date
Internal Verifier
signature
Date
Programme Leader
signature (if required)
Date
Higher Nationals - Summative Assignment Feedback Form
Student Name/ID
Narayana Mudiyanselage Udesh Ishanka / Kan-00142214
Unit Title
Unit_01:PRO - Programming
Assignment Number
01
10.12.2022
Submission Date
Miss. Shifani Mohideen
Assessor
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
Formative Feedback: Assessor to Student
Action Plan
Summative feedback
Feedback: Student to Assessor
Date
Assessor
signature
Udeshishanka9@gmail.com
Student
signature
10.12.2022
Date
Pearson Higher Nationals in
Computing
Unit 01: Programming
Assignment 01
General Guidelines
1. A Cover page or title page – You should always attach a title page to your assignment.
Use previous page as your cover sheet and make sure all the details are accurately filled.
2. Attach this brief as the first section of your assignment.
3. All the assignments should be prepared using a word processing software.
4. All the assignments should be printed on A4 sized papers. Use single side printing.
5. Allow 1” for top, bottom , right margins and 1.25” for the left margin of each page.
Word Processing Rules
1.
2.
3.
4.
The font size should be 12 point, and should be in the style of Time New Roman.
Use 1.5 line spacing. Left justify all paragraphs.
Ensure that all the headings are consistent in terms of the font size and font style.
Use footer function in the word processor to insert Your Name, Subject, Assignment No,
and Page Number on each page. This is useful if individual sheets become detached for any
reason.
5. Use word processing application spell check and grammar check function to help editing
your assignment.
Important Points:
1. It is strictly prohibited to use textboxes to add texts in the assignments, except for the
compulsory information. eg: Figures, tables of comparison etc. Adding text boxes in the body
except for the before mentioned compulsory information will result in rejection of your
work.
2. Carefully check the hand in date and the instructions given in the assignment. Late
submissions will not be accepted.
3. Ensure that you give yourself enough time to complete the assignment by the due date.
4. Excuses of any nature will not be accepted for failure to hand in the work on time.
5. You must take responsibility for managing your own time effectively.
6. If you are unable to hand in your assignment on time and have valid reasons such as illness,
you may apply (in writing) for an extension.
7. Failure to achieve at least PASS criteria will result in a REFERRAL grade .
8. Non-submission of work without valid reasons will lead to an automatic RE FERRAL. You will
then be asked to complete an alternative assignment.
9. If you use other people’s work or ideas in your assignment, reference them properly using
HARVARD referencing system to avoid plagiarism. You have to provide both in-text citation
and a reference list.
10. If you are proven to be guilty of plagiarism or any academic misconduct, your grade could be
reduced to A REFERRAL or at worst you could be expelled from the course
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.
Udeshishanka9@gmail.com
Student’s Signature:
(Provide E-mail ID)
Date: 10.12.2012
(Provide Submission Date)
Higher National Diploma in Computing
Assignment Brief
Student Name /ID Number
Narayana Mudiyanselage Udesh Ishanka / Kan-00142214
Unit Number and Title
Unit 01: Programming
Academic Year
2021/22
Unit Tutor
Miss. Shifani Mohideen
Assignment Title
Design &Implement a GUI based system using a suitable
Integrated Development Environment
Issue Date
Submission Date
10.12.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 (IDE).
LO3. Implement basic algorithms in code using an IDE.
LO4. Determine the debugging process and explain the importance of a coding
standard
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), 7-seater van and Commuter van. New vehicle types are to be added in the future.
Vehicle rent and hire options are described below.
1. Rent (With or without driver) – For each type of vehicle rates are given per day, per week
and per month. Rate for a driver also given per day. Depending on the rent period the total
rent amount needs to be calculated. For example: if a vehicle is rented for 10 days with a
driver, total amount to be calculated as follows:
Total rent = weeklyRent x 1 + dailyRent x 3 + dailyDriverCost x 10
2. Hire (with driver only) – These are based on packages such as airport drop, airport pickup,
100km per day package, 200km per day package etc. Standard rates are defined for a
package type of a vehicle typeif that is applicable for that type of vehicle.For each package
maximum km limit and maximum number of hours arealso defined. Extra km rate is also
defined which is applicable if they run beyond the allocated km limit for the tour. For day
tours if they exceed max hour limit,a waiting charge is applicable for extra hours. Driver
overnight rate and vehicle night park rate also defined which is applicable for each night
when the vehicle is hired for 2 or more days.
Activity 3
Function 1: Rent calculation.
Return the total rent_value when vehicle_no, rented_date, return_date, with_driver
parameters are sent in. with_driver parameter is set to true or false depending whether the
vehicle is rented with or without driver.
Function 2: Day tour - hire calculation.
Calculate total hire_value when vehicle_no, package_type, start_time, end_time,
start_km_reading, end_km_reading parameters are sent in. Should return base_hire_charge,
waiting_charge and extra_km_charge as output parameters.
Function 3: Long tour - hire calculation.
Calculate total hire_value when vehicle_no, package_type, start_date, end_date,
start_km_reading, end_km_reading parameters are sent in. Should return base_hire_charge,
overnight_stay_charge and extra_km_charge as output parameters.
Write suable algorithms for vehicle tariff calculation for rents and hires. Ideally 3
functions should be developed for this purpose as above. Use the visual studio IDE
(using C#.net) to Implement the above algorithms and design the suitable database
structure for keeping the tariffs for vehicle types and different packages which must be
used for implementing the above functions.
Analyze the features of an Integrated Development Environment (IDE) and explain how
those features help in application development. Evaluate the use of the Visual
StudioIDE for your application development contrasted with not using an IDE.
Activity 4
4.1 Design and build a small system to calculate vehicle hire amounts and record them in a
database for customer billing and management reporting forAyubo drive. This includes the
completing the database design started in 3.2 and implementing one or more GUIs for
vehicle, vehicle type, and package add/edit/delete functions. It essentially requires an
interface for hire calculation and recording function described above. Generating customer
reports and customer invoices are not required for this course work.
4.2 Explain debugging process and the features available in Visual studio IDE for debugging
your code more easily. Evaluate how you used the debugging process to develop more
secure, robust application with examples.
4.3 Outline the coding standards you have used in your application development. Critically
evaluate why a coding standard is necessary for the team as well as for the individual.
Grading Rubric
Grading Criteria
LO1 Define basic algorithms to carry out an operation
and outline the process of programming an
application.
P1Provide a definition of what an algorithm is and outline
the process in building an application.
M1Determine the steps taken from writing code to
execution.
D1 Evaluate the implementation of an algorithm in a suitable
language. Evaluate the relationship between the written
algorithm and the code variant
Achieved
Feedback
LO2 Explain the characteristics of procedural,
objectorientated and event-driven programming,
conduct an analysis of a suitable Integrated
Development Environment (IDE)
P2Give explanations of what procedural, objectorientated,
and eventdriven paradigms are; their characteristics and the
relationship between them.
M2 Compare and contrast the procedural, object
orientated and event driven paradigms used in given
source code of an application
D2Critically evaluate the source code of an application which
implements the programming paradigms, in terms of the
code structure and characteristics.
LO3Implement basic algorithms in code using an IDE.
P3Write a program that implements an algorithm using an
IDE.
M3Use the IDE to manage the development process of the
program.
D3Evaluate the use of an IDE for development of
applications contrasted with not using an IDE.
LO4 Determine the debugging process and explain
the importance of a coding standard
P4Explain the debugging process and explain the debugging
facilities available in the IDE.
P5Outline the coding standard you have used in your code.
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.
HND 78
BATCH
PROGRAMMING ASSIGNMENT
N.M.Udesh Ishanka
Contents
Activity 1 ....................................................................................................................... 4
Activity 2 ..................................................................................................................... 12
2.0 Programming Paradigms ................................................................................ 12
2.0.1 What is a programming paradigm? ..................................................... 12
2.1 Structured Programming Paradigm................................................................ 14
2.2 Functional Programming Paradigm ............................................................... 14
2.3 Using the Procedural and Imperative Programming Paradigms in Python
Language. ............................................................................................................. 24
2.3.0 Using the Object Oriented Programming Paradigms in Python
Language. Object Oriented Programming Characteristics .......................... 25
Activity 3 ..................................................................................................................... 33
3.0 Algorithms for vehicle tariff calculation for rents and hires.......................... 33
3.1 Database structure for keeping the tariffs for vehicle types and different
packages and Console Applications..................................................................... 36
3.2.0 Integrated Development Environment (IDE).............................................. 44
Activity 4 ..................................................................................................................... 48
4.0 The system to calculate vehicle hire amounts and record .............................. 48
4.1 What is debugging an application? ................................................................ 52
4.2 Coding standards ............................................................................................ 55
References .................................................................................................................... 60
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 1
Table of Figure
Figure 1 ........................................................ Error! Bookmark not defined.
Figure 2 ........................................................................................................ 13
Figure 3 ........................................................................................................ 14
Figure 4 ........................................................................................................ 14
Figure 5 ........................................................................................................ 14
Figure 6 ........................................................................................................ 15
Figure 7 ........................................................................................................ 15
Figure 8 ........................................................................................................ 17
Figure 9 ........................................................................................................ 18
Figure 10 ...................................................................................................... 18
Figure 11 ...................................................................................................... 19
Figure 12 ...................................................................................................... 20
Figure 13 ...................................................................................................... 21
Figure 14 ...................................................................................................... 21
Figure 15 ...................................................................................................... 24
Figure 16 ...................................................................................................... 25
Figure 17 ...................................................................................................... 25
Figure 18 ...................................................................................................... 26
Figure 19 ...................................................................................................... 27
Figure 20 ...................................................................................................... 28
Figure 21 ...................................................................................................... 28
Figure 22 ...................................................................................................... 29
Figure 23 ...................................................................................................... 29
Figure 24 ...................................................................................................... 30
Figure 25 ...................................................................................................... 30
Figure 26 ...................................................................................................... 31
Figure 27 ...................................................................................................... 31
Figure 28 ...................................................................................................... 32
Figure 29 ...................................................................................................... 37
Figure 30 ...................................................................................................... 37
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 2
Figure 31 ...................................................................................................... 38
Figure 32 ...................................................................................................... 38
Figure 33 ...................................................................................................... 39
Figure 34 ...................................................................................................... 39
Figure 35 ...................................................................................................... 40
Figure 36 ...................................................................................................... 40
Figure 37 ...................................................................................................... 41
Figure 38 ...................................................................................................... 41
Figure 39 ...................................................................................................... 42
Figure 40 ...................................................................................................... 42
Figure 41 ...................................................................................................... 43
Figure 42 ...................................................................................................... 44
Figure 43 ...................................................................................................... 48
Figure 44 ...................................................................................................... 49
Figure 45 ...................................................................................................... 49
Figure 46 ...................................................................................................... 50
Figure 47 ...................................................................................................... 50
Figure 48 ...................................................................................................... 51
Figure 49 ...................................................................................................... 51
Figure 50 ...................................................................................................... 52
Figure 51 ...................................................................................................... 52
Figure 52 ...................................................................................................... 53
Figure 53 ...................................................................................................... 54
Figure 54 ...................................................................................................... 54
Figure 55 ...................................................................................................... 55
Figure 56 ...................................................................................................... 56
Figure 57 ...................................................................................................... 57
Figure 58 ...................................................................................................... 58
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 3
Activity 1
1.0 Algorithm
1.0 .1 What is an Algorithm?
An algorithm is a procedure used for solving a problem or performing a
computation. Algorithms act as an exact list of instructions that conduct specified
actions step by step in either hardware- or software-based routines.
Algorithms are widely used throughout all areas of IT. In mathematics and computer
science, an algorithm usually refers to a small procedure that solves a recurrent
problem. Algorithms are also used as specifications for performing data processing
and play a major role in automated systems.
1.0 .2 What are different types of algorithms?
There are several types of algorithms, all designed to accomplish different tasks. For
example, algorithms perform the following:

Search engine algorithm. This algorithm takes search stringsof keywords
and operators as input, searches its associated database for relevant webpages
and returns results.

Encryption algorithm. This computing algorithm transforms data according
to specified actions to protect it. A symmetric key algorithm, such as the Data
Encryption Standard, for example, uses the same keyto encrypt and decrypt
data. As long as the algorithm is sufficiently sophisticated, no one lacking the
key can decrypt the data.

Greedy algorithm. This algorithm solves optimization problems by finding
the locally optimal solution, hoping it is the optimal solution at the global
level. However, it does not guarantee the most optimal solution.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 4

Recursive algorithm. This algorithm calls itself repeatedly until it solves a
problem. Recursive algorithms call themselves with a smaller value every time
a recursive function is invoked.

Backtracking algorithm. This algorithm finds a solution to a given problem
in incremental approaches and solves it one piece at a time.

Divide-and-conquer algorithm. This common algorithm is divided into two
parts. One part divides a problem into smaller subproblems. The second part
solves these problems and then combines them together to produce a solution.

Dynamic programming algorithm. This algorithm solves problems by
dividing them into subproblems. The results are then stored to be applied for
future corresponding problems.

Brute-force algorithm. This algorithm iterates all possible solutions to a
problem blindly, searching for one or more solutions to a function.

Sorting algorithm. Sorting algorithms are used to rearrange data structure
based on a comparison operator, which is used to decide a new order for data.

Hashing algorithm. This algorithm takes data and converts it into a uniform
message with a hashing

Randomized algorithm. This algorithm reduces running times and timebased complexities. It uses random elements as part of its logic.
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.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 5
1.0 .3 Characteristics of a good algorithm are,
 Input and output should be defined accurately.
 Each step in the algorithm should be clear and unmistakable.
 Algorithms should be most effective among many different ways to solve a problem.
 An algorithm should not contain computer code. Instead, the algorithm
should be written in -such a way that it can be used in different programming
languages.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 6
1.1. Pseudo Codes
1.1.1. Pseudo Code for Fibonacci
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 7
1.1.2. Pseudo Code for Factorial
1.2. Steps Involved in the process of writing and executing a program
 Defining the program
Assume you're referred to as a programmer because others need your help to examine
the issue, you meet with client users or a systems analyst who outlines the project. To
define, choose what you already know (relevant information provided) and what you
want to learn (output-the outcome). You'll ultimately have a formal agreement
outlining the required input, processing, and output types of input, processing, and
output that are required, among other things. It is not an easy task.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 8
 Planning the Solution
This is the initial stage of programming, and it entails gathering the following data.
These items are critical for the programmer because they give a foundation for
planning and controlling future problems that may develop.
 Coding the Program
In this stage, the programmer writes the instructions to solve the issue in a computer
language. The entire coding procedure is dependent on the information gathered in the
preceding phases. The needs and facilities available with a language influence the
language's choice.
 Testing the Program
In this stage, we test the program by entering fake data (typical, unusual, and invalid
data) to see how the software reacts to the provided data.
 Documenting the Program
Most programmers ignore this step for a variety of reasons, yet it is critical since it
will assist the programmer in correcting any errors that may arise in the software.
1.3. Dry Runs
1.3.1. Dry Run for Fibonacci
I
i==0
i = =1
Output
0
True
False
0
1
False
True
0
2
False
False
1
3
False
False
2
4
False
False
3
5
False
False
5
6
False
False
8
7
False
False
13
8
False
False
21
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 9
9
False
False
34
1.3.2. Dry Run for Factorial
N
Output
6
Factorial of 6 is 6
Factorial of 6 is 30
Factorial of 6 is 120
Factorial of 6 is 360
Factorial of 6 is 720
Factorial of 6 is 720
1.4. Big-O Notation
1.4.1. What is Big-O Notation
Big O notation is the language we use to describe how long an algorithm takes to run
(time complexity) or how much memory an algorithm consumes (space complexity).
Big O notation can be used to represent an algorithm's best, worst, and average-case
execution times. For our purposes, we'll concentrate on Big-O in terms of time
complexity.
1.4.2. Big-O Notation Role in Evaluating efficiencies of Algorithms
It is crucial to analyze the number of operational steps involved in the execution of an
algorithm when analyzing its efficiency, regardless of the programming the language
used, or the computer system on which it is performed. When we represent the stages
as an equation, we can claim that the efficiency of an algorithm is equal to the most
prominent component of that equation. By treating each operational step in the
algorithm as a fundamental unit of computing, the execution time of an algorithm may
be stated as an equation. In certain circumstances, an algorithm's performance is
determined by the exact values of the data rather than the magnitude of the issue. We
may examine the performance of such algorithms in terms of best-case,
average case, and worst- case situations, with the best case reflecting a data-set
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 10
where the algorithm performs best. Most data sets produce average-case scenarios for
such algorithms. The number of operational steps in an algorithm and the most
dominating component can be used to determine algorithm efficiency. The order of
magnitude (Big-O notation) the function is the dominant part.
1.4.3. Fibonacci sequence using Big O Notation
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 11
1.4.4. Factorial sequence using Big O Notation
Activity 2
2.0 Programming Paradigms
2.0.1 What is a programming paradigm?
Programming paradigm is a method to deal with problems using some programming
language or additionally we can say it is a strategy to solve a problem using tools and
methods that are accessible to us following some methodology. There are lots for
programming language that are well-known but all of them need to follow some
approaches when they are implemented and this methodology is paradigms. There are
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 12
two main programming paradigms, an Imperative and a Declarative, and there are
numerous paradigms that are inclined by these two types.
Figure 1
Imperative Programming Paradigm (Procedural)
The main objective of the imperative programming paradigm development is to
decrease expenses of program development as well as maintenance. It is a style or
method of writing a program. A procedural programming paradigm is derived from
structured programming. It is based on the concept of the procedure call. Procedures
are also known as sequences, subsequences, approaches, or functions. A Procedure
contains a chain of instructions coupled to be carried out.
Imperative Programming Paradigm is related to two other paradigm
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 13
Figure 2
2.1 Structured Programming Paradigm
Structured Programming means that the code will implement the instructionbyinstruction 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
Figure 3
Figure 4
2.2 Functional Programming Paradigm
Functional Programming are specially designed to handle representative computation
and list processing applications. Functional programming is based on mathematical
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 14
functions and avoids changing state and variable data. The characteristics of
Procedural Programming are as follows,
Figure 5
Figure 6
 A huge program is broken down into small convenient procedures or
functions.
This decreases code repetition, which improves read ability and
maintainability of the code.
 Different functions can share data through global variables.
Functions are completely isolated; therefore, if we want to share data, we
need to declare it in the upper scope.
 Functions can change global data
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.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 15
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
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.
Restrictions or disadvantages of procedural programming
1. Concentrates on functions rather than data.
2. In a huge program, it is difficult to classify the belonging of global data.
3. The use of global data is error-prone and it could be a barrier in case of
maintenance and developments.
4. The modification of global data involves the modification of those functions using
it. Maintaining and improving the program code is still difficult because of global
data.
5. The procedural programming paradigm does not model the real-world problem
very well since functions are action-oriented and do not really agree to the elements of
the problem. Object Oriented Paradigm.
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
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 16
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.
The characteristics of Object Oriented programming are as follows,
Figure 7
 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."
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 17
Figure 8
 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.
Figure 9
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 18
 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.
Figure 10
 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.
A comparison between Procedural and Object Oriented Programming
Procedural
Object Oriented
Uses immutable data
Uses mutable data
Follows the declarative programming Follows the imperative programming
model
model
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 19
Extends support to parallel programming
Not appropriate for parallel programming
The execution order of statements is not The execution of statements is very
the primary focus
important
Flow control is performed using function Flow control
calls
Uses
is
performed through
conditional statements and loops
recursion
concept
to
iterate Uses loop concept to iterate collective
collective data
data
No side effects of its functions
The method can have side effects
The focus in procedural programming is The
“What are you doing”
focus
in
object
oriented
programming is “How are you doing it
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 11
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 20
Figure 12
Figure 13
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 21
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 preset 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.
Events (Mouse, keyboard and user interface)
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.
Pre-defined functions
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 22
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.
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
Parameter passing is used by a function, it tolerates a value to be passed through a
program, it can be used for many things, including an alarm or discovering a certain
character at a certain position, through on an alarm, the event doesn’t take place up
until a certain time has come, this is due to events.
Advantages of Event-driven Programming
 Flexibility
Event-driven can be changed easily if the programmer desires something to
be changed. This paradigm lets the programmer to create a form of their
requirements.
 Appropriate for Graphical Interfaces
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.
 Appropriate for Graphical Interfaces
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.
 Allows for more Interactive Programs
It allows for more interactive programs. Nearly all modern GUI programs use
event driven programming.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 23
 Using Hardware Interrupts
It can be executed using hardware interrupts, which will decrease the power
used by the computer.
Allows sensors and other hardware
It allows sensors and other hardware to effortlessly interact with the software.
Disadvantages / Constraints of Event-driven Programming Complexity For simple
programs, event-driven programming is often more complex. Less Logical, The flow
of the program is usually less logical. Difficult to find Errors Errors can be more
difficult to discover than with simpler, procedural programs.
 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.
2.3 Using the Procedural and Imperative Programming Paradigms in
Python Language.
Figure 14
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 24
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
Figure 15
2.3.0 Using the Object Oriented Programming Paradigms in Python
Language. Object Oriented Programming Characteristics
 Classes and Objects
 Encapsulation
 Inheritance
 Polymorphism
 Class in Python Language
Figure 16
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.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 25
 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.
Figure 17
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.
Encapsulation in python programming language
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 26
Figure 18
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,
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 27
Figure 19
Inheritance in python programming language
Figure 20
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 28
In inheritance, another class (called subclass) inherits a “class”. The subclass adds
some attributes to superclass.
Shown below is the Output,
Figure 21
Polymorphism in Python Programming Language
Figure 22
Can produce function that can take any object allowing for polymorphism
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 29
Figure 23
Event driven in Python Programming Language
Time driven even
Figure 24
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,
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 30
Figure 25
Key-press Events
Figure 26
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 31
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.
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.
Mouse Events
Figure 27
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.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 32
Activity 3
3.0 Algorithms for vehicle tariff calculation for rents and hires.
Function 1: Rent calculation.
Function
RentCalculation(RegNo,RentedDate,ReturnDate,WithDriver)
/*Calculate No of Elapsed Days
DateDiff=ReturnDate –RentedDate
/*calculate months,weeks,days
Months=DateDiff / 30
Remainder = DateDiff % 30
Weeks = Remainder / 7
Days = Remainder % 7
Find the required vehicle record from vehicle table If
(found)
Show VehicleType,MonthlyRate,WeeklyRate,DayRate,DriverRate
Amount= Months*MonthlyRate + Weeks*WeeklyRate + Days*DayRate
If(With_Driver == true)
Total_Amount= Amount+Date_Diff*DriverRate
Else
Total_Amount=Amount
End if
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 33
Print("Total amount",total_amount")
Else
Print("Vehicle Not found")
End if
End function
Function 2: Day tour.
Function day tour (packageid.start_time,end_time,start_km,end_km) Find the
required record from package_table
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 34
Function 3: Long tour.
Function Long_tour(Pid,Start_date,End_date,Start_KM,End KM) Find the required
record from Package_table
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 35
3.1 Database structure for keeping the tariffs for vehicle types and
different packages and Console Applications
The Database structure for Packages is displayed below.
Packages Design
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 36
Figure 28
Pacckages Data
Figure 29
The Database structure for Vehicles is displayed below,
Vehicle Design
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 37
Figure 30
Vehicle Data
Figure 31
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 38
Console Application
Figure 32
Figure 33
The Output for Rent calculation,
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 39
Figure 34
Day Tour
Figure 35
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 40
Figure 36
Figure 37
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 41
Figure 38
Long Tour
Figure 39
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 42
Figure 40
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 43
Figure 41
3.2.0 Integrated Development Environment (IDE)
What is an IDE (Integrated Development Environment)?
An IDE or integrated development environment is a software application that
combines, in one place, all the tools needed for a software development project. On a
more basic level, IDEs provide interfaces for users to write code, organize text
groups, and automate programming redundancies. But instead of a bare-bones code
editor, IDEs combine the functionality of multiple programming processes into one.
IDEs often possess or allow the insertion of frameworks and element libraries to build
upon base-level code.
Throughout the writing process, one or multiple users create hierarchies within the
IDE and assign groups of code to their designated region. From these, groupings
can be strung together, compiled, and built.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 44
Most IDEs come with built-in debuggers, which activate upon the build. Visual
debuggers are a substantial benefit of many IDEs. If any bugs or errors are spotted,
users are shown which parts of the code have problems.
IDEs are especially suited for complex programming as they allow for better coding
assistance, code completion, debugging, visual representation of code, and deep
program analysis. Depending on the language, these IDEs can include templates,
syntax highlighting, and code folding to improve the overall development experience.
IDE vs. text editor
While IDEs have a significantly more extensive range of capabilities, there are
situations when text editors are easier to use and better suited to complete a task.
Users who write a simple script or whip up some basic HTML will likely utilize a text
editor rather than a complex IDE. Text editor software still has syntax highlighters
and search capabilities.
Why is an IDE important?
Throughout the process of writing, creating, and testing software, developers employ
a variety of tools. Text editors, code libraries, bug tracking software, compilers, and
test platforms are among the most common development tools. A developer who does
not use an IDE has to choose, deploy, integrate, and monitor these tools individually.
An integrated development environment combines several of these developmentrelated technologies into a single framework. When all utilities are represented on the
same workbench, developers don't have to spend hours learning how to operate them
separately. This is also handy for new developers who may use an IDE to learn about
a team's standard tools and practices.
Most IDE capabilities, such as intelligent code completion and automatic code
creation, are designed to save time by eliminating writing out complete character
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 45
sequences. The integrated toolset aims to make software development easier while
also detecting and reducing code errors and typos.
Other popular IDE features assist developers in streamlining their workflow and
problem-solving. IDEs parse code as it is written, identifying problems caused in real
time. Most IDEs also include syntax highlighting, which employs visual clues to
discern grammar in the text editor.
Contrasting with not using an IDE
It's possible to develop apps without using an IDE. Developer can create their own
IDE by manually integrating services with a lightweight text editor such as Vim. This
method appeals to certain developers since it allows for extreme flexibility and
control. However, in the workplace, the productivity gains, environment uniformity,
and automation capabilities of current IDEs generally outweigh other factors.
Benefits of not using an IDE
Remember syntax, subroutines, library features
By not using an IDE, you have to remember the syntax of the language you are using,
the subroutines from your own project and their arguments. You also remember
(standard-) library subroutines better for your chose programming language.
Get to know your way around a Project
When you have to manually find a file to change a subroutine implementation, or to
refactor a subroutine, you will have good file names and a good directory structure.
The Anti pattern of the directory layout of your typical Java Enterprise Project is a
Testament to this. (src/main/java/org/company/product/...)
Avoid long IDE startup time / Achive better system performance
With big projects, it might slow you down to have the IDE load the entire project
before you can start working. Some Projects with 40000+ files might take >5 minutes
to load.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 46
some languages/projects are very unergonomic without an IDE
This is almost always the result of bad language design and/or bad library design.
An example is developing android apps in Java with Android studio. Here, you will
be slowed down a great deal in order to program without Android Studio. There will
be a steep learning curve.
Better accessibility of your Project
Good Open Source Projects encourage people to clone, fork, and maybe even to
contribute to a Project. People are able to directly edit files on github, if an IDE is not
required and they know the language being used. Not requiring an IDE makes it easier
for blind people, who might be using screen readers to understand your project, and
enables people without modern hardware (which might be unable/impractical to run
an IDE) to work on your project.
Avoid IDE lock-in of your project
Have you ever seen a Java Enterprise Project? Sometimes the Java classes in there
have 20+ import statements, automatically generated by the IDE. Working in this
style, with such long package names and lots of classes/namespaces eventually almost
forces you to use an IDE because there is just so much, that it becomes impractical to
remember.
Less Code, Better Readability
Not having Autocomplete / Code Generation guides you naturally to writing more
compact and idiomatic Code in the Language of your Choice. It helps you to learn
language-specific features and syntactic sugar.
Consider
System.out.println("hello");
printf("hello");
You
see
that
in
C,
where
using
an
IDE
is
uncommon,
the
languge/libraries/frameworks naturally becomes more easily readable and writable.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 47
Activity 4
4.0 The system to calculate vehicle hire amounts and record
Database record for customer billing and management reporting for Ayubo.
Login Interface
Figure 42
Main Menu Interface
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 48
Figure 43
Package details interface
Figure 44
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 49
Vehicle Details
Figure 45
Rent Calculation Interface
Figure 46
Day Tour Interface
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 50
Figure 47
Long tour interface
Figure 48
Backend Code for Rent Calculation
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 51
Figure 49
Backend Code for Long Tour Calculation
Figure 50
4.1 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
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 52
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.
The debugging process,
1. Reproduce the problem.
2. Describe the bug. Try to be as much input from the user to get the precise reason.
3. Capture the program snapshot when the bug appears. Try to get all the variable
values and states of the program at that time.
4. Examine the snapshot based on the state and action. Based on that try to find the
Cause of the bug.
5. Fix the existing bug, but also check that any new bug does not occur
 The features available in Visual studio IDE for Debugging,
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 51
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.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 53
Figure 52
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.
Figure 53
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 54
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).
Figure 54
4.2 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
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 55
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.
The coding standards that I have used in my application development are,
Code Comments and Proper Documentation
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 55
4.2.0 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,
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 56
Figure 56
4.2.1 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.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 57
Figure 57
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
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 58
will be efficient so the programmer can develop the program within the given time
period.
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.
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 59
References
Available at:
https://medium.com/@bhattshlok12/characteristics-of-an-algorithm-49cf4d7bcd9
Accessed by (2022/12/5)
Available at:
https://www.techtarget.com/whatis/definition/algorithm
Accessed by (2022/12/5)
Available at:
https://shiverware.com/app-development/7-steps-app-development.html
Accessed by (2023/03/20)
Available at:
http://neonbrand.com/procedural-programming-vs-object-oriented-programmingareview/
Accessed by (2022/12/5)
Available at:
https://www.edrawsoft.com/flowchart/program-flowchart-definition.html
Accessed by (2022/12/5)
Available at:
http://www.cs.cornell.edu/courses/cs482/2003su/handouts/pseudocode.pdfJacobson,
Accessed by (2022/12/5)
Available at:
https://blog.usejournal.com/how-to-write-pseudocode-a-beginners-guide29956242698
Accessed by (2022/12/5)
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 60
Available at:
https://medium.com/karuna-sehgal/a-simplified-explanation-of-the-big-o-notation82523585e835
Accessed by (2022/12/5)
Available at:
https://shiverware.com/app-development/7-steps-app-development.html
Accessed by (2023/03/20)
Available at:
https://www.codementor.io/learn-programming/3-essential-algorithm-examples-youshould-know
Accessed by (2023/03/20)
Available at:
https://towardsdatascience.com/demystifying-binary-search-bed0274e27e7
Accessed by (2022/12/5)
Available at:
https://searchsoftwarequality.techtarget.com/definition/integrateddevelopmentenvironment
Accessed by (2022/12/5)
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 61
Name : N.M Udesh Ishanka |Subject : Programming | Assignment No : 01|
ID : Kan-00142214
Page 62
Download