0% found this document useful (0 votes)
56 views

Esoft Programmin Sem01 Assesment

Uploaded by

nethminik839
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Esoft Programmin Sem01 Assesment

Uploaded by

nethminik839
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 45

Higher Nationals - Summative Assignment Feedback Form

Student H.W Kaveesha Nethmini E236837


Name/ID
Unit Title Unit 01 – Programming
Assignment 1 Assessor
Number
2024- Date Received
Submission 10-14 1st
Date submission
Date Received
Re-submission 2nd submission
Date

Assessor Feedback:

LO1. Define basic algorithms to carry out an operation and outline the process of programming an
applicant

Pass, Merit & Distinction Descripts P1 P2 M1 D1

LO2. Explain the characteristics of procedural, object-orientated and event-driven programming,


conduct an Integrated Development Environment (IDE).

Pass, Merit & Distinction Descripts P3 M2 D2

LO3. Implement basic algorithms in code using an IDE.

Pass, Merit & Distinction Descripts P4 M3 D3

LO4. Determine the debugging process and explain the importance of a coding standard.

Pass, Merit & Distinction Descripts P5 P6 M4 D4

* 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.

1
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
Assessor Feedback:

Grade: Assessor Signature: Date:


Resubmission Feedback:

• Please note resubmission feedback is focused only on the resubmitted work

Grade: Assessor Signature: Date:


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.

Important Points:

1. It is strictly prohibited to use textboxes to add texts in the assignments, except for
compulsory information. eg: Figures, tables of comparison etc. Adding text boxes to

2
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
the body except for the before mentioned compulsory information will result in
rejection of your work.
2. Avoid using page borders in your assignment body.
3. Carefully check the hand in date and the instructions given in the assignment. Late
submissions will not be accepted.
4. Ensure that you give yourself enough time to complete the assignment by the due
date.
5. Excuses of any nature will not be accepted for failure to hand in the work on time.
6. You must take responsibility for managing your own time effectively.
7. 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.
8. Failure to achieve at least PASS criteria will result in a REFERRAL grade.
9. Non-submission of work without valid reasons will lead to an automatic RE FERRAL.
You will then be asked to complete an alternative assignment.
10. 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
intext citation and a reference list.
11. 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
12. Use word processing application spell check and grammar check function to help
editing your assignment.
13. 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.

STUDENT ASSESSMENT SUBMISSION AND DECLARATION


When submitting evidence for assessment, each student must sign a declaration
confirming that the work is their own.

3
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
Student name: H.W Kaveesha Assessor name:
Nethmini

Issue date: Submission date: Submitted on:


16/07/2024 2024-10-14 2024-10-14

Program: Pearson BTEC HND in Computing

Unit: Unit 01 – Programming


Assignment number and title:
Building a Leave Management System for Grifindo Lanka Toys (Pvt) Ltd.

Plagiarism
Plagiarism is a particular form of cheating. Plagiarism must be avoided at all costs and
students who break the rules, however innocently, may be penalized. It is your
responsibility to ensure that you understand correct referencing practices. As a
university level student, you are expected to use appropriate references throughout and
keep carefully detailed notes of all your sources of materials for material you have used
in your work, including any material downloaded from the Internet. Please consult the
relevant unit lecturer or your course tutor if you need any further advice.

Guidelines for incorporating AI-generated content into assignments: The use of AI-
generated tools to enhance intellectual development is permitted; nevertheless,
submitted work must be original. It is not acceptable to pass off AI generated work as
your own.

Student Declaration
Student declaration

4
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
I certify that the assignment submission is entirely my own work, and I fully understand
the consequences of plagiarism. I understand that making a false declaration is a form of
malpractice.

Student signature: Nethmini Date: 2024-10-14

Unit 01: PROGRAMMING

Assignment Brief
Student Name/ID Number E236837

Unit Number and Title Unit 01 – Programming

Academic Year 2024/2025

Unit Tutor

Assignment Title Building a Leave Management System for Grifindo Lanka


Toys (Pvt) Ltd.
Issue Date 16/07/2024

Submission Date 14/10/2024

Submission Format

The assignment submission is in the form of the following.


• The submission should be in the form of an individual written report written in a
concise, formal technical style using single spacing and font size 12. • Student has to
submit the complete GUI System with the database.

Table of Contents
a. Activity 01 10
1.1 What is Algorithm? 10
5
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
1.2 Properties of good Algorithm 11
1.3 Process of writing and executing a program 12
1.3.1 Problem Definition 12
1.3.2 Problem Analysis 12
1.3.3 Algorithm Development 12
1.3.4 Coding and Documentation 12
1.3.5 Testing and Debugging 12
1.3.6 Maintenance 12
1.4 Potential Challenges Faced 13
1.5 Fibonacci Series 14
1.6 Factorial Value 16
1.7 Creating an application 17
1.8 Dry Run for Fibonacci Series 17
1.9 Dry Run for Factorial Value 18
1.10 What is big O notation? 19
1.11 Role of Big O Notation in Code Optimization 21
1.12 Fibonacci Series into python code 21
1.13 Factorial Value into python code 23
2.Activity 02 24
2.1 What is Paradigm? 24
2.1.1 Procedural Programming 25
2.1.2 Object Oriented Programming 26
2.1.3 Event driven Programming 29
2.1.3.1 Characteristics 29
2.1.4 Relationship among them 30
3.Activity 03 31
3.1 Pseudo code for Application 31
3.2 Database Design 32
3.2.1 Admin Requirements 32
3.2.2 Employee Requirements 33
3.2.3 Relationships 33

6
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
3.3 Conceptual Design 33
3.4 Logical Design 34
3.5 IDE 36
3.6 Advantages OF visual Studio IDE 38
4.Activity 04 39
4.1 Debugging Process 39
4.2 Coding Standards 41
4.3 Advantages of Coding Standards for Teams 42
4.4 Advantages of Coding Standards for Individuals 43
5.References 45

7
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
Table of Figures
Figure 1: 3 main steps of an algorithm (Simplilearn, 2024)........................................................................3

Figure 2:Fibonacci Series Example (imaginationstationtoledo.org, 2021)...................................................7

Figure 3 TIME COMPLEXITIES OF BIG O NOTATION....................................................................................13

Figure 4: Types of Programming Paradigms (TECHNOLOGY, 2023)...........................................................17

Figure 5: An Example for Procedural Paradigm (BARTONÍČEK, 2014)......................................................18

Figure 6: Main concepts of OOP (BARTONÍČEK, 2014)..............................................................................19

Figure 7: Inheritance (TECHNOLOGY, 2023).............................................................................................20

Figure 8: Example for Classes and Objects (TECHNOLOGY, 2023)..............................................................21

Figure 9: ArrayOutofBoundException Example..........................................................................................33

8
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
1. Activity 01

1.1 What is Algorithm?

This algorithm concept first appeared nearly 40,000 years ago. The Babylonians created the
world's first known mathematical algorithms on clay tablets. ‘The word “algorithm” itself
originated from the name of a 9th-century Persian mathematician, “Muḥammad ibn Mūsā al-
Khwārizmī” ’ (Ellis Horowitz , Sartaj Sahni, Sanguthevar Rajasekaran, 1997) . This is one of the
strongest foundations for the most advanced mathematical, programming, and even in the
medical field, new inventions.

An algorithm is an amazing word that represents most of our activities today. We do things
according to a random algorithm, but we don’t know it. When we are cooking something, we
have several steps which are in procedural order to do. That bunch of well-organized steps is also
an Algorithm. If you and I are cooking the same curry at the same time in the same place, you
could cook in a different method rather than me—the same output but in different steps. So, we
can’t tell what that algorithm means, that procedure must be in the same way. If someone goes to
school by bus and while his neighbor goes to school on foot. They both have their procedure to
go to school. When we consider those incidences, we can understand that most of our
performance in daily routing is based on the concept of algorithm.

An algorithm is a formalized, abstract description of a computational process in the language


of computer science (Dourish, 2016). According to Dourish (2016), algorithms can be classified
into several types based on their properties.

Figure 1: 3 main steps of an algorithm (Simplilearn, 2024)

As you can see in the above diagram, an algorithm contains main 3 steps. According to
Simplilearn (2024) said,

 Input => After implementation of an algorithm, while executing it we provides various


kinds of inputs that are relevant to our requirements. Those inputs can be text, image,
graph or any kind of media.

9
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
 Process = > After abstracting all the required data via user inputs, CPU analyze them and
executing various logics and convert those data into information.

 Output => After the processing activity, it returns valuable information, which we wanted
through the algorithm

1.2 Properties of a good Algorithm

According to the Simplilearn (2024), A good algorithm can make things easy and perfect.
There are several qualities in such an algorithm. (1) Efficiency: algorithms should be more
effective. The best output that can be given within a minimum time and minimum usage of
computer memory and CPU, can be identified as a good algorithm. (2) Correctness: We are
using algorithms for different kinds of activities. When we consider a chemical experiment
process, we must deal with dangerous elements. So, the process and its steps should be clear and
correct. So, to be a good algorithm it must have correctness. (3) Simplicity: If we create an
algorithm and no one can understand it, then it will be a big problem. Even if we are correct, our
project can be rejected. So, an algorithm must be simple, well-implemented, and user-friendly.
(4) Maintainability: It must be declared as easy to make modifications without total harm to the
initial process. If this is so, the users can be confused about suddenly changing the whole project,
and this can lead to mistrust. (5) Security: We are fully globalized now. Most of our credentials,
secret details, and bank details are stored, traversing through the internet. So, the Security of an
algorithm has become the most important thing today. (6) Documentation: If we created some
procedure to do an activity, we should keep good comments or separate documentation about
that procedure, what, why, how to use it, and so on. Without a good explanation it will be
worthless. (7) Robustness: It means an algorithm can handle every kind of user input without
crashing the application or stopping the whole process. If it is not so, we can’t get reliable output.
With these features algorithms could be more reliable, effective and advanced.

1.3 Process of Writing and Executing a Program

When we are developing a program, we have predefined several steps to perform which are
affecting for good quality output.

According to gpmanesar.ac ( n.d.), These steps are known as software development life cycle. It
typically consists of 6 phases as,

1. problem definition
2. problem analysis
3. algorithm development
4. coding and documentation
5. testing and debugging
10
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
6. maintenance

Let’s discuss furthermore about them.

1.3.1 Problem Definition

In this step, we are evaluating user requirements, what outcomes they are expecting, and what
details we should input to get appropriate outcomes.

1.3.2 Problem Analysis

In this step we are deciding what are the functions we are using, what are the limitations of our
output, and what are the variables we are using. That means gathering necessary resources to
address the problem outlined in previous step.

1.3.3 Algorithm Development

In this phase, we design an organized method to resolve the problem based on the
specifications provided in the previous phase. This stage is essential for program development.
Therefore, we express the solution by presenting a series of statements in a sequential manner.

1.3.4 Coding and Documentation

In this phase, a programming language is utilized to write and execute the programming
instructions that were defined in the previous stage. During this stage, we develop an actual
software application. That implies that we develop the software to resolve the specified problem
utilizing programming languages such as C, C#, Java, python and so on.

1.3.5 Testing and Debugging

In this stage we are executing our code again and again with all possible user inputs to ensure
that there are not any possible errors which can crash our program. If we found one, we fix and
re doing the testing process until we satisfy.

1.3.6 Maintenance

During this stage, the program is actively used by the users. If any improvements are
identified during this step, all of the phases must be performed in order to implement the
changes. In the event that the user experiences any difficulties or desires any improvements, it is
necessary to go through all the stages from the beginning in order to resolve the encountered
problem or incorporate the enhancement.

11
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
1.4 Potential Challenges faced

When we are implementing the code, we have to face different kinds of issues. Let’s discuss
about few of them,

1. Syntax errors
• As beginners, we are committing numerous mistakes when coding. Issues with
spelling, absence of covalent bonds, inability to recall the code, and similar difficulties.
Fortunately, we are currently programming using exceptional Integrated Development
Environments (IDEs), which promptly notify us if we make an error.

2. Logical Errors
• If we fail to understand the situation accurately, we may develop incorrect concepts
and produce output that is not relevant to our requirements.

3. Lack Performance
• When we were unable to discover the most optimized code for our challenge, our
program's efficiency decreased. Therefore, the processing time will be longer than our
first estimation.

4. Controlling the user Inputs


• In any application, it is important to restrict user access to input boxes and prevent
them from entering arbitrary data. Control should only be used to obtain the desired
outcome from the user. If this isn't the case, hackers could potentially introduce harmful
programs into our system.

5. Simplify the code


• We must implement our code with simple concepts at all possible events, because it
will increase our codes’ readability and maintainability.

6. Debugging
• The debugging process is pretty hard because we have to focus on whole code line by
line to find where could be the problem.

7. Sitting of hours
• When programming sometimes we have to spend approximately the whole day sitting
in front of the PC. It will cause lots of medical problems.

8. Syntax errors
 As beginners, we are making lots of errors while coding. Spelling problems,
Missing covalent, forgotten the code and so on. Luckily, we are now coding with great
IDE so, it will inform us whenever we did mistake
12
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
9. Logical Errors
 When we couldn’t get the problem clearly, we can make wrong concepts and
given output also not related to our requirements.
10. Lack Performance
 When we couldn’t find the most optimized code to our problem and then our
programs efficiency become less. So, it will take more time to process than we
thought.
11. Controlling the user Inputs
 In any application we shouldn’t give access to the user to enter anything he wants
in our input boxes. We should control only to get what we want from the user. If
it is not so, hackers can inject malicious codes into our program
12. Simplify the code
 It is very important that maintaining our code with simple concepts as much as
we can. It will increase the readability, maintainability of our code
13. Debugging
 Sometime the debugging process is very difficult and challenging. We had to
consuming lot of time to fix the errors
14. Sitting of hours
 When we are engaging with creating an application, we have to dedicate our
time, and other work. We have to work while sitting on a chair for hours.

1.5 Fibonacci Series

Figure 2:Fibonacci Series Example (imaginationstationtoledo.org, 2021)

The Fibonacci Series can be represented by 0, 1, 1, 2, 3, 5, 8, 13, and so on. This is the process of
adding two consecutive numbers and creating a 3rd number. It Starts with 0 and then 1. Step 01:
Step 02: So, we can create 2 variables called a and b and initialize them as a=0 and b=1. As you
can see these 2 variables represent the first two variables of the Fibonacci series. We are
conducting this process by adding 2 variables. Therefore, we need another variable called “sum”
to store the newly created value. It means that the value of the third number of the series. The
user can Input the number he wants that until which number we should display the series. So, we
declare another new variable called “n”. When we are again and again doing this process, we
need to update about the position in the series. Because we should know whether we already
13
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
have displayed n numbers or not. Step 03: Now we need to know the user-defined number which
means n. So, we get user input for that. Step 04: Step 05: As the first 2 numbers of the series, we
can display a and be. Now the actual finding series part begins. Step 06: In step 06 we are doing
steps 07,08,09,10,11 again and again, while the condition of i<=n, is true. When i becomes
greater than n, we stop the loop. Step 07: In this algorithm, we create the 3rd number by adding
the previous 1st and 2nd numbers. So, here we can add a+b and an initialized variable called
“sum” as sum = a+b. Step 08: We need to propagate through the series until we meet the nth
number. So, we can replace the 1st number with be 2nd number by setting a=b. Step 09: In the
previous step we propagate a to the 2nd element, So, now we need to propagate b to the 3rd
element by replacing an as b=sum. Because, because we already know that sum is the newly
created 3rd element. Step 10: We have already displayed a and b before the loop begins. After
that, we didn’t display or take any input from the user. So, we can identify numbers in our series
in the right order. Now, we can display the 3rd number sum Step 11: As I mentioned previously,
we should know the position that we are in. So, in this step, we are updating the position
identifier which is called “i” as i=i+1, because we are propagating one by one. So, until i
becomes greater than n, this process will continue. Step 12: This is the end of the algorithm.
Because we displayed the nth number of the Fibonacci series.

Step 01 – Start

Step 02 – Set a=0, b=1, sum=0, i=2 and Declare n

Step 03 – Input n

Step 04 – Display a

Step 05 – Display b

Step 06 – while i<=n, Repeat 07, 08, 09, 10, 11

Step 07 – sum = a+b

Step 08 – a=b

Step 09 – b = sum

Step 10- Display sum

Step 11– i=i+1

Step 12 – End

14
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
1.6 Factorial Value

Factorial of n can be represented as n * (n-1) * (n-2) * (n-3) *…. * (n-(n-1)). As an example,


factorial of 6 can be represented as 6*5*4*3*2*1. Both examples are the same thing but the first
one with a variable and second one with raw data. Step 01: Step 02: Here I have declared 3
variables called n, i and factorial. I took n to store the user input, i to handle the position and the
factorial to store our number series. I will explain them separately in their steps. Step 03: Here I
set an input to get user idea about that what is the number I should deal with. And it was stored in
the variable n, which was declared in the previous step. We already know the if user defined
number is n, we have to represent n numbers as factorial of n. Step 04: The representation of
factorial is mostly in descending order. So, we already know the first value of our series, that is
n. nth Position is 1st so, here I have set i = 1. Step 05: Then, I have initialized our factorial
variable with factorial = n, the theory is same as what I mentioned. Step 06: Here is the
beginning of our loop. In this step we are doing step 07,08 again and again until we met i=n. As
soon as we met i=n, the loop will break. Step 07: We have already created factorial value, so
here we can add next value of (n-1) by factorial *=n-i. in next step we increment i value by 1. So,
i is a dynamic variable and it gives us all the numbers in factorial series when we subtract it from
n value. Step 08: Here we are incrementing i value by 1. So, code can be dynamically changed.
We are continuously doing Step 07 and 08 until we met i=n. Step 09: Here we can display the
final output of the factorial variable. It represents the n!

Step 01 – Start

Step 02 – Declare variables n, i, factorial

Step 03 – Input n : (“Insert any number: ”)

Step 04- Set i = 1

Step 05 – Initialized factorial = n

Step 06 – Repeat Step 07- 08 until i=n,

Step 07 – Factorial *=n-i

Step 08- i = i + 1

Step 09- Display Factorial

Step 10 - End

15
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
1.7 Creating an application

When we create an application there are several main steps we should follow. Such as,

(1) Understanding the Problem

(2) Creating an algorithm

(3) Coding

(4) Testing and debugging

(5) Maintain the code

According to the above steps, the second stage is the creating an algorithm. First, we should
understand what the requirements are we should fulfill through our application. After that we can
create an algorithm to understand how it works. It will be easier to implement the code without
many changes. While implementing the code we should do proper documentation. After you
implement the code, also you have to test it with all possible user inputs and check whether what
can crash our application and we should correct the errors in an optimized way. If all
requirements are covered and there are no possible errors while running, we can publish our
application. But we must maintain our application to UpToDate and if there are new requirement,
we should update the code.

1.8 Dry Run for Fibonacci Series

Step 01 – Start

Step 02 – Set a=0, b=1, sum=0, i=2 and Declare n

Step 03 – Input n

Step 04 – Display a

Step 05 – Display b

Step 06 – while i<=n, Repeat 07, 08, 09, 10, 11

Step 07 – sum = a+b

Step 08 – a=b

Step 09 – b = sum
16
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
Step 10- Display sum

Step 11– i=i+1

Step 12 – End

 Let’s assume n=3

Step a b i sum n Output


Step 01
Step 02 0 1 2 0
Step 03 3
Step 04 0 0
Step 05 1 1
Step 06 2
Step 07 1 1
Step 08 1
Step 09 1
Step 10
Step 11 3
Step 07 2 2
Step 08 1
Step 09 2
Step 10
Step 11 4
Step 12

So, by this series outputs are 0, 1, 1, 2 while n=3

1.9 Dry Run for Factorial Value

Step 01 – Start

Step 02 – Declare variables n, i, factorial

Step 03 – Input n : (“Insert any number: ”)

Step 04- Set i = 1

Step 05 – Initialized factorial = n

Step 06 – Repeat Step 07- 08 until i=n,

Step 07 – Factorial *=n-i


17
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
Step 08- i = i + 1

Step 09- Display Factorial

Step 10 – End

 Let’s assume n=3

Step n i factorial output


Step 01
Step 02
Step 03 3
Step 04 1
Step 05 3
Step 06 3 1 3
Step 07 1 3*(3-1) =6
Step 08 2
Step 06 3 2 6
Step 07 2 6*(3-2) =6
Step 08 3
Step 09 6 6
Step 10

So, by this n! is 6. This is the final output.

1.10 What is Big O Notation?

When we create a program, we need to know how efficient our application or performance of
our application is. We measure efficiency by considering space complexity and time consumed.
Big O notation is a mathematical language used to describe how the time complexity or space
complexity of an algorithm scales with the size of the input. It specifically targets the worst-case
situation, which refers to the most challenging or lengthiest conceivable input for the algorithm.
Space complexity measures the memory consumed amount by the increasement of size of the
input and time complexity measures the amount of time consumed by the increment of the size
of the input. Big O Notation measures the worst-case scenario. It means the maximum amount of
time or space that can be consumed by our application per input. It helps to gain understand
about performance of our code and help to make optimized program with best performances.

In big O notation there are 7 main types of complexities. I will describe it according to the time.
But the space complexity theory is the same.

1. O(1) => Constant time complexity. The time remains same as every size of inputs
18
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
 Example: When we want to get the value of array[2], here we know the index, so we
don’t need to traverse through the array. Therefore, if we know an index, amount of time
consuming is same for all results

2. O(log n) => Logarithmic time complexity. The time is also increase logarithmically based
on input size
 Example: Binary search algorithm is the best example for this.

3. O(n) => Linear time complexity. Times grow proportional to the input size in linear way
 Example: Bubble sort algorithm is the best example for this. Mostly applied on
loops

4. O(n log n) => Linearithmatic time complexity. Times grow proportional to the n log n
5. O(n^2) => Quadratic time complexity. Times grow quadratically according to the input
size
6. O(2^n) => Exponential time complexity
7. O(n!) => Factorial time complexity

(Olawanle, 2022)

Figure 3 TIME COMPLEXITIES OF BIG O NOTATION

According to this chart is shows that the best scenarios in this order,

 O(1) - Excellent/Best

 O(log n) - Good

 O(n) - Fair

 O(n log n) - Bad

19
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
 O(n^2), O(2^n) and O(n!) - Horrible/Worst

1.11 Role of Big O in Efficiency Optimization

According to studysmarter.co (2024), Big O notation can be used to optimize our code as
follows.

1. Performance Comparison
 It helps programmers compare which algorithm is more suitable for a given
scenario using a simple calculation. Besides that, they have to actually implement
all possible algorithms, and then they have to test them one by one to find the best
algorithm.
2. Scalability Insight
 You can predict which algorithms, methods, and design patterns are suitable for
each task based on the variation in dataset sizes. If you have to deal with a large-
scale dataset, you can simply apply the big O notation, find the O(?) value, and
compare each value according to the above graph.

By using this knowledge you can implement more productive and efficient programs. This big O
provides you the capability to predict and manage how your program will perform with the
variations of inputs. Each algorithm possesses its own unique combination of advantages and
disadvantages. There is no universally applicable solution. By utilizing Big O Notation and
conducting algorithm complexity analysis, you can acquire the capacity to identify versatile and
reliable algorithms that are most suitable for your specific scenarios and tasks (studysmarter.co,
2024).

1.12 Fibonacci Series into Python code

def Fibonacci_Series(n):
#Step 02- Initialized a,b,sum,i
a=0
b=1
sum=0
i=2

#Step 04,05 - Display a,b


print(a)
20
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
print(b)

#step 06
while i<=n:
sum = a+b #Step 07
a=b #step 08
b = sum #step 09
print(sum) #step 10
i += 1 #step 11

n = (int(input("Enter any number: "))) #Step 03


Fibonacci_Series(n)

 Let’s find out efficiency of our program

o Step 02-Step 05 => Here is the part of initialization of variables and displaying variables.
Those steps have no loop or binary search, bubble sort or any kind of different time-
consuming steps. So, all steps take constant time. So the big o notation is O(1). Also, in
step 03 input n, but it also not affected to the result
o Step 06-Step 11 => Here is the loop part. Step 07,08,09,10,11 all takes constant time as I
mentioned in above point, but here we are doing these steps again and again (n-1) times
to fulfill while i<=n condition. So, time will proportionally depend on n. The big O
notation is O(n)
o We got 2 notation, but as I mentioned below the diagram, O(n) is worse than O(1).
According to the big O notation we normally take the worst-case scenario. So, Big O of
our program is O(n)

1.13 Factorial Series into Python code

21
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
def Factorial_Series(n):
#Step 04
i=1

#step 05
factorial = n

#step 06 - Repeat until i=n


while i<n:
factorial *= (n-i) #step 07
i += 1 #Step 08
print(factorial) #display mid values of factorial
print("Final Output:")
print(factorial) #Display final output

n = (int(input("Enter any number: "))) #Step 03


Factorial_Series(n)

 Let’s find out efficiency of our program


 Step 01-05 => Here is the part of initialization of variables and displaying variables.
Those steps have no loop or binary search, bubble sort or any kind of different time-
consuming steps. So, all steps take constant time. So the big o notation is O(1). Also, in
step 03 input n, but it also not affected to the result
 Step 06- Step 08 => Here is the loop part. Step 07,08 all takes constant time as I
mentioned in above point, but here we are doing these steps again and again (n-1) times
to fulfill while i<n condition. So, time will proportionally depend on n. The big O
notation is O(n)
 We got 2 notation, but as I mentioned below the diagram, O(n) is worse than O(1).
According to the big O notation we normally take the worst-case scenario. So, Big O of
our program is O(n)

22
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
Activity 02
2.1 What is paradigm?

Figure 4: Types of Programming Paradigms (TECHNOLOGY, 2023)

As developers, we have to deal with different kinds of problems. To solve them in efficient
ways, firstly we should decide the best paradigm which we are using to develop our software.
Because it’s the based foundation of readability, maintainability and efficiency of our code.
Paradigm means the approach or basic structure of the code. As BARTONÍČEK (2014) said, By
the word paradigm, we understand a set of patterns and practices used to achieve a certain goal.
It defines how to work programming languages, their rules, principles and concepts. In the
practical world a single language can have multiple types of paradigms. There are lots of
paradigms, but only a few of them are mainly used in the software development field. As
examples,
 Imperative programming (Procedural programming)
 Declarative programming
 Object-oriented programming
 Event-driven programming
 Functional programming
 Logic programming
 Reflection programming
 Generic programming…etc. (BARTONÍČEK, 2014)

2.1.1 Procedural programming (Imperative Programming)


As BARTONICEK (2014) mentioned in his report, in this paradigm, the program consists of a
sequential sequence of instructions for the computer to execute, following the order in which
23
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
they were written, unless specified otherwise. The technique is straightforward and highly
legible. when the software is of a relatively small size. Programs of greater magnitude designed
using a procedural approach in consideration might be highly challenging to comprehend,
oversee, and troubleshoot.
Most early programming languages are procedural programming languages. They are the list
of instructions which are given to the computer to inform that what to do next. All the
instructions are coded according to a step-by-step concept. So, procedural languages are also
known as top-down languages. Examples are Fortran, c and Cobol.
 Use sequences, selections, repetitions
 Can be easily translated into machine language
 Computer use reusable memory
 Source code is portable
 Program flow can be easily tracked

Figure 5: An Example for Procedural Paradigm (BARTONÍČEK, 2014)

#include <stdio.h>
void greeting() {
printf("Hello, World!");
}
int main() {
greeting();
return 0;
}

24
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
 This is a simple code snippet of c language which represents a simple function to greet
someone. The main function is the first block which executes, then it meets greeting ()
function. So, the interpreter goes to void greeting code block and after executing it,
simply returns from the main function.
 The flow is clearly from top to bottom, but always starts with the main function.
 Separate functions are used to reduce the complexity of the code.
 As well as function, we can use repetitions and selections to do various tasks.
 While we used the main function as int main (), return 0 is must.

2.1.2 Object-oriented programming


As said by BARTONÍČEK (2014), Alan Kay established the Object-oriented paradigm during
his work on Smalltalk. This tool was created with the purpose of facilitating the management of
huge projects and distributing the burden among colleagues. Its simplicity is achieved via the use
of modular items.
This can be identified as a new trend of the programming paradigm. This method consists of
classes and objects. Classes represent the real-world entities while objects are the new container
which represent a single instance of the parent class. It means that an object can access all the
public properties and methods of its class. Examples for OOP languages are java, PHP, Python
etc.…There are several common features in OOP,

Figure 6: Main concepts of OOP (BARTONÍČEK, 2014)

 Encapsulation => which means preventing direct access to the variables and methods in
parent class by applying access modifiers like public, private, protected. It wraps up data
into a single unit. Developers can choice whether they should be public, private or
protected.

 Inheritance => Which means sub-classes can inherit all the properties and methods in
parents’ classes by extending to parent class. But only can have access according to the
access modifiers visibilities. As TECHNOLOGY (2023) said, Inheritance is the
mechanism via which objects from one class gain the characteristics of objects from
another class. It embraces the notion of hierarchical classification. In object-oriented
25
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
programming (OOP), the concept of inheritance allows for the reuse of code. This
implies that we have the ability to incorporate supplementary functionalities to an
already existing class without making any alterations to it. It is crucial because it
reinforces the notion of categorization. C++ facilitates various forms of inheritance,
including single inheritance, multiple inheritance, multilevel inheritance, and
hierarchical inheritance.

Figure 7: Inheritance (TECHNOLOGY, 2023)

 Polymorphism => Which means the ability to override methods of parent classes at
subclasses. As well as overload methods in same class, with same name methods but
different types of parameters. According to TECHNOLOGY (2023), Polymorphism,
derived from the Greek language, refers to the capacity to assume multiple forms. A
given procedure may manifest varying behavior in different cases. The behavior is
contingent upon the sorts of data utilized in the procedure. The fundamental notions of
polymorphism are operator overloading and function overloading.

 Abstraction => Abstraction means we are creating complex logics by hiding them from
users to make the application user friendly. Which means the users can only do their
tasks without knowing the whole internal process. According to TECHNOLOGY (2023),
Abstraction is the process of describing the fundamental characteristics of something
without introducing unnecessary details or explanations. Classes employ the principle of
abstraction and are characterized as a collection of abstract characteristics such as size,
weight, and cost, together with functions to manipulate these characteristics. The
attributes are referred to as data members as they store information. The operations that
manipulate these data are referred to as member functions.

 Objects and classes => Objects are the instances of parent class while classes are the
main structure code of the object, which consists of methods and properties of the
significant object. Objects are able to engage without possessing knowledge of the
specific intricacies of each other's data or code. An object is a delineated region of
computer memory that stores data and a collection of functions capable of accessing that
data. A class is a grouping of items which share the same types of properties. Every
object is linked to a specific class that used to construct it (TECHNOLOGY, 2023).

26
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
Figure 8: Example for Classes and Objects (TECHNOLOGY, 2023)

Here is a simple code snippet of PHP which representing OOP


<?Php
Class Animal{
Public string $sound;
Public function __construct (string $sound) {
$this->sound = $sound ;
}
Public function makeSound() :string {
Return “making $this->$sound”;
}
}
Class Dog extends Animal{
Public function makeSound(): string {
Return “Bow-Bow”;
}
}
$dog = new Dog(“bow-bow”);
echo $dog->makeSound();

27
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
?>
This small code snippet is consistent with parent class Animal and its sub class which inherit
with animal class called Dog. In Animal class there is a property called sound and a function
called makeSound(). The other function is the constructor of the class which is created when we
initialized an object.
We can override makeSound() function at subclass, so the return string can change according to
the object type. Eg-> dog: bow-bow, cat: meow
But makeSound is a parent class function and all kinds of objects relevant sound can call through
make sound function, without implementing separate functions for each.
 Here you can see, we could prevent redundant codes by using inheritance of classes.
 Also, can secure our application by encapsulation
 Make code more readable, maintainable
 Abstraction makes user-friendly applications
2.1.3 Event-driven programming
Today we are mostly using real-time application with user interactions which have GUI. So,
event-driven programming is used in these applications. If we click a button, key up, key down,
scroll down like wise all the types of user information can be identified by listener which
attached to the relevant part. Example languages are c#,js,etc…
An event-driven program is a program that operates based on the occurrence of external events,
determining the flow of control within the program. Event-driven software typically continues in
a state of waiting for events, selecting which events to reply to, responding to them, and then
returning to its waiting state. Event-driven programs require both an event recognition
mechanism and an event handling mechanism. Event-driven programs are required to function
accurately in an environment where unforeseen, dynamic, external stimuli originate from many
sources such as people, hardware, or other processes (cs.hunter.cuny.edu, n.d.).
2.1.3.1 Characteristics:
 Event Listener: Monitors for specific events.
 Event: An action or occurrence detected by the program.
 Event Source: The origin of the event.
 Event Loop: Keeps checking for new events and triggers corresponding handlers.

document.getElementById("myButton").addEventListener("click", function() {
alert("Hello, World!");
28
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
});
This is a javascript code which has a button called myButton and it has attached an eventListner.
When we click the button, there will be an alert with the text hello world. In event-driven
programming, it happens again and again whenever trigger the eventListner. It can be mouse
click, mouse hover, keyup, keydown or whatever user interaction or sensor detection.
Here is a small code snippet of C#,
private void btnBack_Click(object sender, EventArgs e)
{
wfAdminHome wfAdminHome = new wfAdminHome(pass,id);
wfAdminHome.Show();
this.Hide();
}
2.1.4 Relationship among them

Aspect Procedural Paradigm OOP paradigm Event-driven


paradigm
Based on Based on the concept Based on objects and Based on attached
of procedure calls, classes. eventListener trigger
executes from top to when user action or
bottom by line by line sensor detection
Key concept Functions, repetitions, Objects, classes, Event Listener, event,
selections encapsulation, event source, event
polymorphism, loop
inheritance,
abstraction, interfaces
Control flow Top - bottom Interactions between Whenever trigger the
objects listener
Reusability Low (functions, High (polymorphism, Moderate (callback
modules) interfaces) functions)
Maintainability Difficult with the scale Easy with modularity Complex because
of the code asynchronous nature
Scalability Less scalable High scalable Moderate
Used in Mathematical problem Complex software’s GUI applications
solving
languages C, pascal PHP, java, Python Js, Nodejs, c#, java

Table 1: Differences between above 3 paradigms

29
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
Activity 03
3.1 Pseudocode for Application
Step 01=> Start
Step 02=> Input empID (Input (“EmployeeID: ”))
Step 03 => Select Leave_Type
Step 04=> IF (Leave_Type ==(“Annual Leaves”))
Step 05=> Then Select Leave_Date
Step 06=> IF (Leave_Date – Today) >7)
Step 07=> IF ((Already_Got_Leaves <14)
Step 08=> Then Apply Leaves
Step 09=> Else
Step 10=> Display (“You have Already taken 14 leaves per year”)
Step 11=> End IF
Step 12=> Else
Step 13=> Display (“Please Apply before 7 days”)
Step 14=> End IF
Step 15=> Else IF (Leave_Type ==(“Casual Leaves”))
Step 16=> Then Select Leave_Date_Time
Step 17=> IF (Roaster Time != Leave_Date_Time)
Step 18=> IF ((Already_Got_Leaves <7)
Step 19=> Then Apply Leaves
Step 20=> Else
Step 21=> Display (“You have Already taken 7 leaves per year”)
Step 22=> End IF
Step 23=> Else
Step 24=> Display (“Please Apply before start your roaster”)
30
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
Step 25=> End IF
Step 15=> Else IF (Leave_Type ==(“Short Leaves”))
Step 16=> Then Select Leave _Time
Step 17=> IF (Leave_Time > Now)
Step 18=> IF ((Already_Got_Leaves_In_Month <2)
Step 19=> Then Apply Leaves
Step 20=> Else
Step 21=> Display (“You have Already taken 2 leaves per month”)
Step 22=> End IF
Step 23=> Else
Step 24=> Display (“Please Select on of Upcoming Slots”)
Step 25=> End IF
Step 26=>Else
Step 27=> Display(“Not a Valid Leave Type”)
Step 28=>EndIF
Step 29=>End
3.2 Database Design
3.2.1 Admin Requirements
 Admin details should be stored in DB to validate login. (name, id, password)
 Register new employees to system (employeeName, employeeID, password)
 Assign number of leaves for each employee (employeeID, leaveType, numberOfLeaves)
 Assign roaster to each employee (employeeID, startTime, endTime, Date)
 Approve or reject applied leaves (employeeID, appliedID, Status(approve/reject))
 View leave history of each employee in given date range
 View leave history for all employee in given date range
3.2.2 Employee Requirements
 Employee login
 Apply leaves => short leaves (employeeID, leaveDate, StartTime, endTime)
 Apply leaves => casual, annual (employeeID, LeaveDate, leaveType)
 View leave status of applied leaves
31
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
 Delete applied leaves
 View Remaining leaves
3.2.3 Relationships
 Employee Apply ApplyShortLeaves (1:M)
 Employee Apply ApplyLeaves (1:M)
 Employee have roasterDb (M:M)
 ApplyLeaves CheckedLeaves ApprovedLeaves (1:1)
 ApplyShortLeaves CheckedShortLeaves ApprovedLeaves (1:1)
3.3 Conceptual Design

3.4 Logical Design


 AdminTable (adminID, adminName, adminPassword)
 EmployeeTable (employeeID, employeeName, employeePassword)
 ApproveLeaves (id, employeeID, leaveType, leaveStatus, leaveDate, appliedID*)
32
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
 ApproveShortLeaves (id, employeeID, leaveType, startTime, leaveStatus, leaveDate,
appliedID*)
 AssignLeaves (leaveType, employeeID, numberOfLeaves)
 ApplyLeaves (leaveID, leaveDate, leaveType, employeeID*)
 applyShortLeaves (leaveID, leaveDate, startTime, endTime, employeeID*)
 Apply (applyLeaveID, applyShortLeaveID)
 roasterDb (id, employeeID, startTime, endTime, Date)
 roasterHave (roasterID, employeeID)

CREATE DATABASE Leaves;

use Leaves;

CREATE TABLE adminTable (


adminID varchar(12) PRIMARY KEY,
adminName varchar(60) NOT NULL,
adminPassword varchar(12) NOT NULL,
);

CREATE TABLE EmployeeTable (


employeeID varchar(12) PRIMARY KEY,
emplyeeName varchar(60) NOT NULL,
employeePassword varchar(12) Not NULL
);

CREATE TABLE ApplyLeaves (


leaveID int IDENTITY(1,1) PRIMARY KEY,
leaveType varchar(18) CHECK (leaveType IN ('Annual Leaves', 'Casual Leaves')),
employeeID varchar(12) NOT NULL,
leaveDate Date NOT NULL,
FOREIGN KEY (employeeID) references employeeTable,
);

CREATE TABLE applyShortLeaves (


leaveID int IDENTITY(1,1) PRIMARY KEY,
leaveType varchar(18) CHECK (leaveType IN ('Short Leaves')),
leaveDate Date NOT NULL,
employeeID varchar(12) NOT NULL,
startTime time NOT NULL,
endTIme time NOT NULL,
FOREIGN KEY (employeeID) references employeeTable
);

33
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
CREATE TABLE Apply (
applyLeaveID int NOT NULL,
applyShortLeaveID int NOT NULL,
FOREIGN KEY (applyLeaveID) references ApplyLeaves ON UPDATE CASCADE,
FOREIGN KEY (applyShortLeaveID) references applyShortLeaves ON UPDATE
CASCADE,
PRIMARY KEY (applyShortLeaveID, applyLeaveID)
);

CREATE TABLE ApproveLeaves (


id int IDENTITY(1,1) PRIMARY KEY,
employeeID varchar(12) NOT NULL,
leaveDate date NOT NULL,
leaveType varchar(18) CHECK (leaveType IN ('Annual Leaves', 'Casual Leaves')),
leaveStatus varchar(10) CHECK (leaveStatus IN ('Approved', 'Rejected')),
appliedID int NOT NULL,
FOREIGN KEY (appliedID) references ApplyLeaves ON DELETE CASCADE
);

CREATE TABLE ApproveShortLeaves (


id int IDENTITY(1,1) PRIMARY KEY,
employeeID varchar(12) NOT NULL,
leaveDate date NOT NULL,
startTime time NOT NULL,
leaveType varchar(18) CHECK (leaveType IN ('Short Leaves')),
leaveStatus varchar(10) CHECK (leaveStatus IN ('Approved', 'Rejected')),
appliedID int NOT NULL,
FOREIGN KEY (appliedID) references applyShortLeaves ON DELETE CASCADE
);

CREATE TABLE AssignLeaves (


leaveType varchar(18) CHECK (leaveType IN ('Annual Leaves', 'Casual Leaves', 'Short
Leaves')),
employeeID varchar(12) NOT NULL,
numberOfLeaves int NULL,
PRIMARY KEY (leaveType, employeeID)
);

CREATE TABLE roasterDb (


id int IDENTITY(1,1) PRIMARY KEY,
employeeID varchar(12) NOT NULL,
startTime time NOT NULL,
endTime time NOT NULL,
Date date NOT NULL
34
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
);

CREATE TABLE roasterHave (


roasterID int NOT NULL,
employeeID varchar(12) not null,
PRIMARY KEY (roasterID, employeeID)
);

3.5 IDE
Integrated Development Environment is the best option for developers to make their work
easier, perfect, optimized and readable. There are bunch of different kind of tools are in IDE to
do that. Now a days there are number of IDE are also can be found for different programming
languages. Most of them has below features to make programmers’ lives easier.
As Chicago (2005) mentioned, for instance, numerous Integrated Development Environments
(IDEs) provide utilities that facilitate the creation of graphical interfaces for our personal
programs, commonly referred to as "UI designers". The user can engage with all of these tools
(editor, compiler, etc.) through an interface that typically (but not always) takes the form of a
user-friendly graphical interface. The primary benefit of utilizing an Integrated Development
Environment (IDE) is that it allows the programmer to perform all tasks within a unified
interface, eliminating the need for frequent switching between several tools.
Some popular examples are: -
1. IntelliJ IDEA — Best for Java development
2. PyCharm — Best for smart Python code editing
3. JupyterLab — Best for data science with Python
4. WebStorm — Best for web development with JavaScript
5. NetBeans — Best Maven support
6. Xcode — Best for Apple development
7. RStudio — Best for R
8. Visual Studio Code — Best for Windows application development
9. Android Studio — Best for Android development
10. Selenium IDE — Best test automation features
As geeksforgeeks.org (2024) mentioned at his website most of IDEs contains,

35
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
1. Debugger
 Debugger is one of most important parts of modern IDEs. When we get an error
with our code, we can add a simple break point before the part we assume would
be the error and simply start debugging. Then the IDE interpreted our code line by
line. So, we can clearly identify by which line we catch the error and also IDE
gives us an exception according to the error type.
2. Auto Compilation
 If we are dealing with a compiler-based language, we have to compile our code at
every change. The very depressing part is that while we concentrate to the code,
we might forget to compile the code. As a solution modern IDE gives us build
option to auto compile while starting our program.
3. Show Syntax Errors
 If we have made some syntax errors, The IDE mention them all. So, we don’t
need to worry about it and can implement our code relaxed. If IDE mention and
error, we need to simply go to error line and the error message which highlighted
by red underscore.
4. Version Control Integration
 In moder IDEs we can Integrate our VCS like git, through our IDE terminal as
well as some IDE has a button to simply push our code to GitHub. We have to
only connect our git and GitHub profile into our IDE. So, you don’t have worry
about every time git add, git push commands
5. Collaboration Feature
 There is a feature to live share our code with other developers. It will make our
works easier because we can make sure our coding part can run with other
developers’ codes
6. Cross-Platform Development
 IDEs can develop applications for web, mobile, desktop as well as when
considering mobile applications both android and iOS. And support for most of
programming languages
7. Extensions / Plugins
 New features can be added to our IDE as extension or plugin. So, we can
customize our IDE to do different kinds of activities as we want
8. Refactoring
 Can make our code more readable and maintainable by refactoring without
impacting to our external behavior
9. Terminal
 Provide integrated terminal for developers to execute commands withing our
IDEs. So, we don’t need to worry about our host OS, windows or whatever we
can try Linux based terminal in our IDE.
10. GUI design Tools
 Visual Studio IDE is most important to create GUI applications without applying
thousands of code-lines. We can simply drag and drop desktop application design.
We only need to do coding part for development the behaviors of our application.
11. Database connection
36
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
 IDEs provide us with database connection for both in localhost as well as cloud
based or remote systems. It is very easy to manage complex applications with this
feature.
3.6 Advantages OF visual Studio IDE
As Quoy (2024) mentioned at her page there are several advantages of using Visual Studio IDE
for coding process,
 IntelliSense provides intelligent code suggestions, greatly improving coding
efficiency, especially for languages like C++.

 Sophisticated Code Profiling allows for a detailed analysis of code and precise
adjustments to enhance performance.

 Personalized Language Support: Customized to fit the specific programming


language being utilized, offering tailored features and assistance.

 Collaboration within a team is improved with specific features designed for group
work, which is ideal for bigger projects.

 Visual Studio provides a complete development experience, made possible by its


strong testing tools such as unit testing and performance profiling. Furthermore,
the smooth incorporation with Azure elevates Visual Studio to a higher level in
cloud development and deployment, broadening opportunities for developers.
As I mentioned above topic, all 11 points are completely valid for visual studio IDE. If we
didn’t use an IDE, we would be truly depressed now. We can’t capture live syntax errors, missing
coding parts, missing semi-covalent, quotes or something. If our code didn’t work, we have to
read the whole code line by line. It’s impossible to pay 100% attention to the whole code. We
have to compile our code at every single change. And we don’t have debugger to check where
we missed the logic.
The most important advantage is visual studio IDE has drag and Drop option for designing part
of our desktop application. We can simply drag the part we want and drop it into new windows
form and simply we can edit them as we want while the IDE is generating the actual raw code
for our design. If we don’t use IDE, we have to hard code all those thousands of codes for doing
same thing. It is worthless and time-consuming work. Can refactor the code to optimize our
application and make it more user-friendly. So, we can minimum redundancy code snippets.

Activity 04
4.1 Debugging Process

37
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
Visual studio is a tool that makes our programming experience easier. One of the main features
in VS is debugging. If you are having a problem with your code, debugging helps you to identify
the problem. VS IDE has a bunch of debugging features which are relevant to different kinds of
situations. You can enter debugging mode by pressing F5 or simply click start debugging button
in the debug toolbar.
Features of debugging in VS IDE
According to microsoft (2023) said,
 Breakpoints
o It has an option called breakpoint, which helps you to pause the execution
at any point that you want. Then you can observe the behavior of your
code, line by line or whatever relevant debugging method. In Visual
Studio, you can quickly set a breakpoint by clicking in the left margin next
to the line of code or place the cursor on a line and press F9 (microsoft,
2023).
 Watch Window
o After you set breakpoint, click the debugging option. Then in the
debugging menu, you can see watch option under windows. By adding a
watch window, you can actively see what the values of each variable are
assigned at every step and the running expressions.
 Immediate Window
o This window can be found in the debug menu, then under the windows
option. You can type your functions names here and can run them
immediately without clicking the play button. This is useful to run small
bits of codes.
 Call Stacks
o This window will show you all the functions you executed till this ongoing
execution point. It is using to understand what the structure of our journey
is
 Locals Window
o The Autos window shows variables used on the current line that the
debugger is at and the preceding line. The Locals window shows variables
defined in the local scope, which is usually the current function or method.
(debug, 2023)
 Step into, Step over, Step Out
o When debugging, these instructions govern how you navigate around your
code. Step Over" executes the current line and continues to the next, "Step
Out" completes the current function and pauses when it returns to the
caller, and "Step Into" takes you inside the functions called on the current
line.
 Hot Reload

38
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
o You have another super crazy option called hot reload to run your
application again after saving some changes without restarting it.
Through these options you can have further idea of the problem in your code. After the
execution IDE will be stuck at exception point which is the place where the problem can be
found. Please go through the code again and again with some breakpoints which are relevant to
your assumptions.
Here is a small code snippet of java, I took that screenshot after debugging it. You can clearly see
that VS code automatically provides us and exception called ArrayIndexOutOfBoundsException.
And the error code line was highlighted. I have tried to call the index 11 item of array, but there
were only 10 indexes. That was the error in my code and VS code helped me to find the error.

Figure 9: ArrayOutofBoundException Example

If we haven’t debugger options and had to build large scale software, there may be thousands
of various kinds of errors which were not identified through test cases. We don’t know about
them so; we published our application without fixing them. Then our application will make our
carrier reputation to the ground level. Users are different to each other. So, there requirements are
also differed. So, different kinds of user inputs, unhandled errors can crash our application. So,
it’s very important that debugging facility in IDE.

Let’s find out how to debug correctly. As microsoft (2023) has marked at their site,
1. Preventing and Fixing bugs
39
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
You can add breakpoints to logic code lines and do testing again and again with
all possible user inputs, and scenarios.
 This prevents transfer bugs into the final project and preventing crash the
application
2. Enhancing Security
 While you are trying all possible scenarios, there aren’t any vulnerabilities that
can remain in our applications. So, it is more secure than normal applications.
Especially when we are validating authentication, observe thoroughly if
credentials are exchanged securely, whether cookies, sessions are matching like
wise.
3. Improving performance
 While testing our code, we can refactor it into more efficient, readable and
maintainable versions. It will optimize our application performance. During the
debugging process, you can find areas of your code that are sluggish or
inefficient. You may enhance the overall functionality of your application and
make it more resilient and responsive by optimizing these components.
 Debugging enables you to keep an eye on how your program utilizes CPU and
memory on the machine. This guarantees that memory leaks and excessive
resource usage won't affect your application's performance.
4.2 Coding Standards
Coding Standards are the best performance standards that should be followed by programmers.
But they are not strict to do. Coding Standards are like ethics. It will increase readability,
maintainability and security of your code. Reduced errors and optimized the application well.
Another "easier said than done" goal is to always develop high-quality code that is simple to
maintain and build upon. As per a recent analysis published by CISQ, the minimum cost of
substandard software in the United States in 2022 was projected to be $2.41 trillion (Anon.,
2023).

Development teams need to follow rules and best practices that help them write better code more
consistently to maintain clean and healthy code. These methods, approaches, and acknowledged
best practices are referred to as coding standards (Anon., 2023).
 Well Structured Naming conventions
 Variable naming conventions => Use camelCase or snake Case naming
conventions.
 Functions => Use camelCase or snake Case naming conventions.
 Classes => First letter capital (use pascal Case)
 Constants => Upper case names

 Code formatting
 Use proper indentations and try to use short methods. Use braces neatly

40
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
 Documentation
 Your code not for only you, so you have to document your theory in brief by
commenting or you can create separate files for explaining the process with examples
 Don’t commenting in long

 Code Structure
 Modularity => Breakdown code into reusable classes or functions
 Single responsible principle => One class can only have one responsibility
 Files management => Place same kinds of files separately at same folder

 Error handling
 Use to wrap your code inside try-catch blocks
 You can test your code by console logging the output

 Version control
 Try to always work with git or any version controller to not to lose your code or can
be easy to restore to previous versions if new version is worst

If we are coding according to the coding standards it is very easy for everyone who review our
code as well as the team that we are working with.
4.3 Important for coding standards for Teams
As mentioned by Yan (2024),
Following coding standards is crucial for both teams and individual developers, as they
provide a set of rules and principles that improve the overall success and efficiency of software
development projects. Implementing coding guidelines establishes a structured framework for
writing code that is easier to read and maintain. Developers discover coding is easier to grasp
and get through by adhering to uniform guidelines and a cohesive format. Prioritizing
organization and minimizing errors is crucial. The importance of adhering to coding standards is
more apparent in a team environment. Through the establishment of a collaborative atmosphere,
they ensure that every team member consistently contributes to the codebase. Consistency in
code is crucial for effective evaluation and collaboration among team members. It simplifies the
process and enhances understanding as a group.
1. Collaboration => we can’t work alone. We should collaborate with other team
members and our code should be clear, well-structured for good understanding for them.
So, we should follow the same principles to code.

2. Code quality => It will increase our code quality and should be readable, maintainable

3. Onboarding => New team members can also get the principles and procedures in your
team quickly. Because coding standards are common to everyone.

41
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
4. Simplify debugging => anyone can understand the code and what happened there, so
they can make assumptions about what should be the error. It makes the debugging
process quicker.

5. Name conventions => quality name conventions make other team members works easier
because, they can get the correct idea of the variables, functions, events etc.

6. Refactoring => Anyone can refactor the code if he has good idea easily

It secures time wasting and easy to maintain the code. If we want to refactor or re-implement our
code with new features, it will not be more complex. Following coding standards improves a
developer's ability to write better code, increasing their value to their team and potential
employers. Coding standards save time by giving developers a clear set of guidelines to follow
when naming variables or formatting code. This enables developers to concentrate more on
finding solutions.
4.4 Important for coding standards for Individuals
As mentioned by Yan (2024),
Enforcing coding standards can greatly simplify code reviews by providing a standardized set of
criteria. By actively identifying problems and incorporating optimal methods into the
development process, the review process improves efficiency, and the code quality is elevated.
Following coding conventions is crucial to ensure the project's scalability
1. Professional growth => Following coding standards will help to achieve your carrier
goals by improving coding skills and can implementing more creative codes

2. Quickly Debugging => You don’t need to spend more time to solve your problems in the
code

3. Efficient code => Your code is more optimized so, efficient applications can be made

4. Code reviews => Reviewers will appreciate you and give good feedback because,
readability of the code

5. Code quality => It will increase our code quality and should be readable, maintainable

6. Easy to Update => you can easily update some features of your code without changing
lots of codes. Eg=> Reusable sections, functions, modules

42
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
7. Mind Relaxing => It is very pleasant when code is well structured, so you can deal it
with more time rather than unstructured code

43
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
References
Anon., 2017. What is an Algorithm?, s.l.: s.n.

Anon., 2023. Coding Standards: What Are They and Why Are They Important?. [Online]
Available at: https://blog.codacy.com/coding-standards

BARTONÍČEK, J., 2014. Programming Language Paradigms & The Main Principles of Object-Oriented
Programming. [Online]
Available at:
https://www.researchgate.net/publication/272577347_Programming_Language_Paradigms_The_Main_
Principles_of_Object-Oriented_Programming
[Accessed 10 08 2024].

Chicago, T. U. o., 2005. CMSC 15200 – Introduction to Computer Science 2. [Online]


Available at: https://www.classes.cs.uchicago.edu/archive/2005/summer/15200-1/labs/
CMSC15200_SUM05_Lab2.pdf
[Accessed 10 08 2024].

cs.hunter.cuny.edu, n.d. Chapter 6 Event Driven Programming. [Online]


Available at: https://www.cs.hunter.cuny.edu/~sweiss/course_materials/unix_lecture_notes/
chapter_06.pdf
[Accessed 10 08 2024].

debug, m., 2023. Tutorial: Learn to debug C# code using Visual Studio. [Online]
Available at: https://learn.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-debugger?toc=
%2Fvisualstudio%2Fdebugger%2Ftoc.json&view=vs-2022

Dourish, P., 2016. Algorithms and their others:, Irvine: Big Data & Society.

Ellis Horowitz , Sartaj Sahni, Sanguthevar Rajasekaran, 1997. Computer Algorithms. 1 ed. New York: W.H
Freeman and Company.

geeksforgeeks.org, 2024. What is an IDE? – Integrated Development Environment. [Online]


Available at: https://www.geeksforgeeks.org/what-is-ide/
[Accessed 10 08 2024].

gpmanesar.ac, n.d. Algorithm and Programming Development. [Online]


Available at: http://www.gpmanesar.ac.in/GPContent/PIC%20NOTES.pdf
[Accessed 07 08 2024].

imaginationstationtoledo.org, 2021. The Fibonacci Sequence. [Online]


Available at: https://www.imaginationstationtoledo.org/about/blog/the-fibonacci-sequence#:~:text=The
44
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01
%20Fibonacci%20sequence%20is%20the,233%2C%20377%2C%20610%2C%20%E2%80%A6
[Accessed 09 08 2024].

microsoft, 2023. Debug for absolute beginners. [Online]


Available at: https://learn.microsoft.com/en-us/visualstudio/debugger/debugging-absolute-beginners?
view=vs-2022&tabs=csharp

Olawanle, J., 2022. Big O Cheat Sheet – Time Complexity Chart. [Online]
Available at: https://www.freecodecamp.org/news/big-o-cheat-sheet-time-complexity-chart/

Quoy, L., 2024. Visual Studio vs Visual Studio Code: What’s the Key Difference?. [Online]
Available at: https://distantjob.com/blog/visual-studio-vs-visual-studio-code/#:~:text=Comprehensive
%20Development%20Environment%3A%20Visual%20Studio,interactive%20debugging%2C%20and
%20code%20profiling.
[Accessed 10 08 2024].

Simplilearn, 2024. What Is An Algorithm? Definition, Types, Characteristics. [Online]


Available at: https://www.simplilearn.com/tutorials/data-structure-tutorial/what-is-an-algorithm
[Accessed 09 08 2024].

studysmarter.co, 2024. Big O Notation. [Online]


Available at: https://www.studysmarter.co.uk/explanations/computer-science/algorithms-in-computer-
science/big-o-notation/#:~:text=in%20computer%20science%3F-,Big%20O%20Notation%20is%20a
%20mathematical%20notation%20used%20to%20represent,comparing%20the%20efficiency%20of
[Accessed 09 08 2024].

TECHNOLOGY, R. C. O. E. A., 2023. INTRODUCTION TO PROGRAMMING PARADIGMS. [Online]


Available at: https://rcet.org.in/uploads/academics/regulation2021/rohini_38341594818.pdf
[Accessed 10 08 2024].

Yan, W., 2024. Coding standards are crucial for teams and individual developers. Mandalay: studocu.

45
H.W Kaveesha Nethmini
Unit 01 – Programming
Assignment 01

You might also like