Programming Assigment Lahiru Sehan
Programming Assigment Lahiru Sehan
Table of Figures........................................................................................................................4
Table of Tables.........................................................................................................................6
Activity 01...............................................................................................................................28
1.1 Algorithms......................................................................................................................28
1.2 Characteristics of a Good Algorithm..............................................................................30
1.3 Pseudo Codes.................................................................................................................32
1.4 Fibonacci Series.............................................................................................................39
1.5 Python Algorithm to Generate both Fibonacci and factorial Series in a Number..........46
Activity 02...............................................................................................................................51
2.1 Programming Paradigms: An Overview..................................................................51
2.2 Characteristics of Procedural Programming............................................................56
2.3 Object-Oriented Programming (OOP).....................................................................65
2.4 Event-Driven Programming...........................................................................................70
Activity 3.................................................................................................................................77
3.1 Pseudocodes of Grifindo Toys Payroll System..............................................................77
3.1.1 Salary Component..............................................................................................................77
3.2: Overview of Visual Studio IDE....................................................................................80
3.1.2 Implementing Visual Studio IDE to the Components..........................................................81
3.2 Creating Separate Classes for Components....................................................................83
3.3 Database Structure Design.............................................................................................86
3.3.1 Database Design Principles.................................................................................................86
3.3.2 Entities and Relationships in Employee System..................................................................87
3.3.3 SQL Table Creation for Employee Information...................................................................88
3.3.4 SQL Table Creation for Salary Information..........................................................................89
3.4 Features of a Integrated Development Environment (IDE)...........................................90
3.4.1 Code Editing and Autocompletion......................................................................................90
3.4.2 Debugging Tools.................................................................................................................90
3.4.3 GUI Design and Form Building............................................................................................91
3.5 Visual Studio IDE for Application Development..........................................................92
3.5.1 Advantages of Using Visual Studio......................................................................................92
3.5.2 Efficiency in Coding and Debugging....................................................................................93
3.5.3 Integration with .NET Framework.......................................................................................94
3.5.4 Visual Studio vs. Manual Development..............................................................................95
Activity 4.................................................................................................................................96
4.1 GUI Grifindo Toys payroll System................................................................................96
4.1.1 Loading Screen....................................................................................................................96
4.1.2 Login Page...........................................................................................................................97
4.1.3 Main Form..........................................................................................................................98
4.1.4 Home..................................................................................................................................99
4.1.5 Employee Component......................................................................................................100
4.1.6 Employe Salary Information Form....................................................................................101
4.1.7 Settings Component..........................................................................................................102
4.1.8 Salary Component............................................................................................................103
4.1.8 View..................................................................................................................................104
4.2 Debugging Process in Visual Studio............................................................................105
Setting Breakpoint.....................................................................................................................105
Inspecting Variables and Values........................................................................................105
Watch and Immediate Windows........................................................................................105
Exception Handling: Exception Handling..........................................................................105
Call Stack...........................................................................................................................105
4..2.1 Debugging Grifindo Toys Project.....................................................................................106
4.3 Coding Standards and outline of Grifindo Toys System..............................................109
4.4 Coding Standards in Software Development.........................................................132
Table of Figures
Table 1 Table 1 Steps and Challenges in The Process of Writing and Executing a Computer
Program....................................................................................................................................36
Figure 2 Factorial of 20 is Calculated(authors work)...............................................................50
Table 3 Database Design Principles(authors work).................................................................86
Table 4 Manual Development Vs Visual Studio(authors work)..............................................95
Table 5 Debugging Processes in Visual Studio......................................................................105
Table 6 Coding Standards......................................................................................................132
Higher Nationals
Internal verification of assessment decisions – BTEC (RQF)
Give details:
LO2. Explain the characteristics of procedural, object-orientated and event-driven programming, con
analysis of a suitable Integrated Development Environment (IDE).
Pass, Merit & Distinction Descripts P2 M2 D2
LO4. Determine the debugging process and explain the importance of a coding standard.
Pass, Merit & Distinction Descripts P4 P5 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.
Assignment Feedback
Formative Feedback: Assessor to Student
Action Plan
Summative feedback
Assessor Date
signature
Student Date
signature
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.
1. The font size should be 12 point, and should be in the style of Time New Roman.
2. Use 1.5 line spacing. Left justify all paragraphs.
3. Ensure that all the headings are consistent in terms of the font size and font style.
4. Use footer function in the word processor to insert Your Name, Subject,
Assignment No, and Page Number on each page. This is useful if individual sheets
become detached for any reason.
5. Use word processing application spell check and grammar check function to help
editing your assignment.
Important Points:
1. It is strictly prohibited to use textboxes to add texts in the assignments, except for the
compulsory information. eg: Figures, tables of comparison etc. Adding text boxes in
the body 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.
Unit Tutor
Issue Date
Submission Date
Submission Format
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.
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, ……..
Fn = F n-1 + F n-2
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 and carry out an analysis of writing the code phase by discussing the potential
challenges faced.
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 Compare and discuss 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) and critically
evaluate the code samples that you have given above in relation to their structure and
the unique characteristics.
Grifindo Toys is a small-scale Toy building company which is located in United Kingdom
(UK) and currently they have 50 employees working at their headquarters. They are looking
for a simple payroll system to calculate the salaries of their employees and you are hired as a
freelance software developer to build their payroll system.
Specifications for the payroll system as follows,
Grifindo Toys Payroll System mainly contains five components and the specifications for
the components are follows,
1. Employee Component.
Admin should be able to register employee details to the system (including
monthly salary, overtime rates-hourly, allowances).
Admin should be able to update all employee details in the system (Update and
Delete including monthly salary, overtime rates-hourly, allowances).
Admin should be able to view individual employee details, view all
employees’ details, search employees.
2. Salary Component
Admin should be able to input the date range to calculate the salary. Salary
cycle begin date and the end date should be given to calculate the monthly
salary. Salary cycle begin date and end date will be defined in the settings
component and if the user enters something else the system should display an
error message.
The admin should be able to enter the no of leaves an employee has taken with
number of absent days, no of holidays for the given date range. If an employee
has worked any overtime hours the admin should be able to enter that also
when calculating the Base pay value.
Base Pay need to calculate based on the following points,
No-pay-value = (Total_Salary/salary_cycle_date_range)
*No_of_absent_days
Base Pay need to calculate according to the below mentioned formula
All the calculated No-pay-value, Base-pay-value and Gross pay value should
record in the database under each employee for each month. This component
should generate reports such as monthly salary report for an employee, overall
salary summary for couple of months for an employee, No-pay-value, base-
pay-value, and gross pay value of all the employees for a given month range.
3. Settings Component
This component should allow the admin to change parameter values such as
i. Date Range for a salary cycle. Eg:- 30 days
ii. Salary cycle begin date.
iii. Salary cycle end date
iv. No of leaves for an employee for a year.
Activity 3
Write the complete pseudocode for the salary component of the above system (report
generation is not needed). Use the visual studio IDE (using C#.net) to implement the
above three components. Ideally there should be three separate classes for the above
three components and the developer can decide the methods which need to include in
those classes. Design the suitable database structure for keeping the data of the above
system.
Analyze the features of an Integrated Development Environment (IDE) and explain
how those features help in application development. Evaluate the use of the Visual
Studio IDE for your application development contrasted with not using an IDE.
Activity 4
2.1 Design and build a small GUI system for the above scenario and it should be a complete
functional system with all the functions which have described in the above scenario with
the database structure which has designed in activity 3.
2.2 Examine 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.
2.3 Explain and 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
1.1 Algorithms
Introduction to Algorithms
An algorithm is a precise, step-by-step set of instructions or a well-defined computational
procedure designed to solve a specific problem or perform a particular task. Algorithms are
fundamental to computer science and are used in various fields, including mathematics, data
processing, and programming.
Algorithms are not merely a fundamental aspect of computer science; they are the backbone of
modern computing. They provide a structured approach to problem-solving that is not limited to
any single domain. Whether you're navigating through complex mathematical equations, sorting
vast datasets, or instructing a computer to perform intricate tasks, algorithms are the guiding
principles that enable these operations to be executed with precision and efficiency.
In essence, algorithms are the intellectual building blocks of computation. They encapsulate
human ingenuity, logic, and problem-solving skills in a format that can be executed by machines.
These step-by-step procedures are like recipes in a cookbook, meticulously detailing each action
required to achieve a desired outcome.
One of the most captivating aspects of algorithms is their universality. They transcend specific
programming languages, hardware architectures, and application domains. An algorithm
developed to solve a mathematical problem can be just as applicable to processing images or
simulating physical phenomena. This versatility highlights the profound impact of algorithms on
diverse fields, from artificial intelligence and cryptography to finance and scientific research.
Efficiency: Algorithms are pivotal in optimizing the use of computational resources, such
as time and memory. Efficient algorithms can significantly reduce the time it takes to
process data or find solutions, making them essential for large-scale applications.
Scalability: In an era of big data and complex computations, algorithms play a crucial
role in ensuring that software systems can scale up to handle increasing workloads
efficiently.
Innovation and Research: Researchers and scientists use algorithms to explore new ideas
and theories. They are essential tools for developing and testing hypotheses.
A good algorithm possesses several key characteristics that ensure its effectiveness and
reliability in solving problems.
Algorithms are the foundation of problem-solving in computer science and beyond. To be
considered effective, an algorithm must exhibit specific characteristics that make it trustworthy,
efficient, and adaptable.
Correctness:
A correct algorithm produces the desired output for all valid inputs. It accurately solves
the problem it was designed for.
Correctness is paramount as an incorrect algorithm can lead to flawed results and costly
errors in applications.
Efficiency:
An efficient algorithm accomplishes its task in a reasonable amount of time and with
minimal resource consumption, such as CPU time and memory.
Generality:
General algorithms are versatile and reusable, saving time and effort in developing
solutions for similar problems.
It aids in identifying potential issues, refining the logic, and optimizing the algorithm's
structure before implementation.
This language independence ensures that the algorithm's design is not limited to a single
programming language, promoting flexibility and adaptability.
The process of writing and executing a computer program involves several key steps, each of
which plays a vital role in turning a problem-solving idea into a functional software application.
1. Planning:
The first step in creating a program is to understand the problem you want to solve
thoroughly. Define the objectives, requirements, and constraints of the software. Plan the
logic and algorithm that will address the problem.
Planning helps ensure that the software will meet the desired goals and that you have a
clear roadmap for development.
2. Coding:
Coding is where you bring your ideas to life. It involves using the syntax and constructs
of a specific programming language to implement your solution.
3. Testing:
After writing the code, thoroughly test the program. Check if it behaves as expected for
various inputs and situations. Identify and fix any errors or bugs (bugs are issues in the
code that prevent it from working correctly).
Testing ensures that the program is reliable and free from critical errors. It helps catch
issues early in the development process.
4. Debugging:
Debugging is the process of identifying, isolating, and fixing errors in the code. It
involves using debugging tools, print statements, or other techniques to locate and correct
problems.
Debugging is an essential part of software development. It ensures that the code functions
correctly and produces the intended results.
5. Execution:
Once you are confident that the code is free from major errors, you execute the program.
This involves running the software with specific inputs or data.
6. Analysis:
After executing the program, analyze its performance. Assess factors like speed, memory
usage, and efficiency. Consider whether the program meets the performance
requirements.
Analysis helps you evaluate the program's effectiveness and identify areas where
improvements can be made.
Authors work
Table 1 Table 1 Steps and Challenges in The Process of Writing and Executing a Computer
Program
7. Optimization Optimize the code for better Optimization can be complex, and
performance or efficiency if optimizing prematurely can make
needed. the code less readable and
maintainable.
Big-O notation allows us to compare algorithms and assess their efficiency. Lower-order
complexities (e.g., O(n)) are generally more efficient than higher-order ones (e.g., O(n^2)).
Evaluating efficiency is crucial when dealing with large datasets or time-sensitive applications
because it helps choose the most appropriate algorithm for the task.
The Fibonacci Series is a fascinating sequence of numbers with a rich mathematical history. It
begins with the numbers 0 and 1, and each subsequent number in the sequence is the sum of the
two preceding ones. In other words, it's a recursive sequence where each term relies on the
previous two. The sequence starts like this: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and so on, extending
infinitely.
The mathematical notation for the Fibonacci series often uses the variable 'Fn' to represent the
nth term of the sequence. It's defined by a recurrence relation: Fn = Fn-1 + Fn-2, where 'Fn-1'
and 'Fn-2' are the two preceding terms. This simple yet elegant mathematical concept has
captured the imagination of mathematicians, scientists, and artists for centuries.
The Fibonacci sequence has far-reaching implications in various fields, including mathematics,
computer science, art, and nature. It's a fundamental example of a recursive mathematical
process, and its beauty lies not only in its simplicity but also in its prevalence in the natural
world, seen in the arrangement of leaves on plants, the spiral patterns of seashells, and the
growth of populations in some biological systems.
In computer science and programming, the Fibonacci sequence is often used as a learning
exercise to understand recursion and dynamic programming. It also plays a role in algorithms
Understanding the Fibonacci Series serves as a bridge between the abstract world of
mathematics and the practical world of computer science, demonstrating how mathematical
principles can be applied to solve real-world problems.
This pseudocode outlines a step-by-step algorithm to generate and display the Fibonacci series
up to the specified number 'n.' It initializes two variables, 'a' and 'b,' with the initial values of 0
and 1, respectively, and then iterates to calculate and display each subsequent number in the
series until reaching 'n.'
Factorial calculation is a common mathematical operation used to find the product of all positive
integers from 1 to 'n.' In this pseudocode, we will outline an algorithm to calculate the factorial
of a given non-negative integer 'n.'
This dry run demonstrates how the algorithm generates the Fibonacci series up to the specified
value of 'n' by iteratively calculating each number in the sequence and updating the variables 'a'
and 'b' accordingly.
In the first iteration (i = 2), we calculate 'c' as the sum of 'a' and 'b,' resulting in 1. We
display 1 as the first number in the Fibonacci series. Then, we update 'a' to 1, 'b' to 1, and
'i' to 3 in preparation for the next iteration.
In the second iteration (i = 3), 'c' is calculated as 2 (the sum of 'a' and 'b'). We display 2 as
the second number in the series. 'a' becomes 1, 'b' becomes 2, and 'i' becomes 4.
In the third iteration (i = 4), 'c' is calculated as 3 (the sum of 'a' and 'b'). We display 3 as
the third number and update 'a' to 2, 'b' to 3, and 'i' to 5.
In the fourth iteration (i = 5), 'c' is calculated as 5 (the sum of 'a' and 'b'). We display 5 as
the fourth number and update 'a' to 3, 'b' to 5, and 'i' to 6/
Since 'i' exceeds 'n' (which is 4), we exit the loop. The Fibonacci series up to 4 is
displayed as 1, 2, 3, 5.
Big-O notation is a way to describe the upper bound of the time complexity of an algorithm in
terms of the input size. It provides a simplified representation of how the algorithm's
performance scales as the input size grows.
O (1): Constant time complexity, where the algorithm's runtime does not depend on the
input size.
O (log n): Logarithmic time complexity, common in algorithms that divide the input in
half at each step.
O (n): Linear time complexity, where the runtime grows linearly with the input size.
O (n log n): Log-linear time complexity, often seen in efficient sorting algorithms.
O(n^2): Quadratic time complexity, where the runtime grows with the square of the
input size.
Fibonacci Series: This algorithm generates the Fibonacci series up to a specified number 'n' and
returns the series as a list.
Factorial Calculation: This algorithm calculates the factorial of a non-negative integer 'n' and
returns the result.
Introduction:
The program is designed to provide a user-friendly way to calculate both the Fibonacci Series
and Factorial of a non-negative integer 'n'. It opens a GUI window with input fields, calculation
buttons, and result displays. This makes it more accessible and visually appealing compared to
a console-based program.
Key Components:
Tkinter GUI: The program starts by importing the Tkinter library and creating a main window
(root). This window serves as the interface for user interaction. It's given a title, dimensions,
and a light gray background.
Within the window, there's a label instructing the user to enter a non-negative integer 'n'. An
entry widget allows users to input their value. Two buttons, "Calculate Fibonacci" and
"Calculate Factorial," trigger the respective calculations when clicked.
Algorithm Implementation:
The program contains functions for calculating the Fibonacci Series and Factorial. These
functions use the same algorithms you provided earlier in the console-based version. When a
user clicks one of the calculation buttons, the corresponding function is called with the user-
provided 'n' value. The result is then displayed in the result label.
User Interaction:
Users can interact with the program by entering a non-negative integer 'n' into the entry field
and clicking either the "Calculate Fibonacci" or "Calculate Factorial" button. The program
takes the input, performs the calculations, and displays the results. This GUI-based approach
enhances user experience and makes the program more intuitive.
Authors Work
Programming paradigms are fundamental approaches or philosophies that guide the design and
structuring of computer programs. They represent distinct schools of thought in software
development, each offering a specific set of principles and conventions for writing code. These
paradigms serve as blueprints for organizing, managing, and reasoning about the logic and
structure of a computer program. By adhering to a particular paradigm, programmers can
effectively express their ideas and solve problems using a well-defined methodology.
Problem-Solving Approach: Paradigms define how programmers’ approach and break down
complex problems into smaller, more manageable components. For example, in procedural
programming, the focus is on dividing tasks into procedures or functions, while in object-
oriented programming, problems are solved by modeling real-world entities as objects with
attributes and behaviors. The choice of paradigm can significantly impact the problem-solving
process.
Code Organization: Each paradigm introduces specific rules and conventions for structuring
code. For instance, object-oriented programming promotes the creation of classes and objects to
encapsulate data and behavior, fostering a clear and organized codebase. Procedural
programming emphasizes structured code using functions or procedures to improve code
modularity. This organization ensures that code is easier to read, maintain, and extend.
Maintainability: The choice of paradigm can greatly impact the maintainability of software.
Object-oriented programming, by encapsulating data and behavior within objects, can lead to
Alignment with Project Goals: Different projects have different goals and requirements.
Choosing the right paradigm ensures that the software development approach aligns
with the project's objectives.
Code Maintainability: The choice of paradigm affects how code is organized and
structured. An appropriate paradigm can lead to well-structured and maintainable code,
making it easier for developers to understand, modify, and extend the software over
time. This is essential for long-term sustainability and cost-effectiveness.
Scalability: Certain paradigms are better suited for handling the scalability requirements
of a project
Efficiency: Certain paradigms may be more efficient than others for specific types of
tasks. For instance, low-level, procedural programming languages like C are often
Ease of Debugging and Testing: The choice of paradigm can impact how easily code
can be debugged and tested. Well-structured code following a suitable paradigm may
have fewer bugs and be more straightforward to test, reducing development time and
costs.
Future Maintenance: When considering the long-term life cycle of software, selecting
the right paradigm can ease future maintenance efforts. A paradigm that supports
modular and organized code allows for smoother updates and enhancements.
User Experience: In the case of user-facing applications, the chosen paradigm can
influence the user experience.
Figure 9 example of procedural code in Python that follows the principles of structured
programming. (authors work)
Create a main frame within the window and configure it to expand and fill available
space.
Create a label and an entry widget for users to input numbers, placing them within the
main frame grid.
Create a "Calculate Average" button that triggers the calculate_average function when
clicked, also placed within the main frame grid.
Create a label to display the calculated average result, positioning it below the input
widgets in the grid.
Figure 11 Code Of My Simple GUI Average Calculator with a procedural code in Python that
follows the principles of structured programming(authors work)
Advantages Disadvantages
This code defines two functions, read file, and write file, for reading the content of a file and
writing modified content to a new file. It demonstrates procedural code for file operations,
emphasizing modularity and readability.
In OOP, code is organized into classes, encapsulating both data (attributes) and behavior
(methods), promoting the principles of encapsulation, inheritance, and polymorphism. This
paradigm enhances code reusability, maintainability, and scalability by modeling software in a
way that mirrors real-world structures.
Prominent programming languages that support OOP include Java, Python, and C++. OOP
enables the development of modular and extensible code, making it a fundamental approach in
modern software engineering and design.
Object-Oriented Programming (OOP) is built upon core concepts that provide a structured and
organized approach to software development. These concepts include:
Classes: Classes serve as blueprints or templates for creating objects. They define the structure
and behavior that objects of a particular type will have. Classes encapsulate attributes (data)
and methods (functions) that operate on that data.
Objects: Objects are instances of classes. They represent real-world entities or concepts and
are created based on class definitions. Each object has its own set of data and can perform
actions defined by its class.
Encapsulation: Encapsulation involves bundling data (attributes) and methods (functions) that
operate on that data into a single unit called a class. Access to the internal data of a class is
controlled through defined interfaces, enhancing data security and modularity.
Benefits Challenges
Code Reusability: OOP promotes the reuse of Complexity Management: Larger systems
classes and objects. In larger systems, this may involve numerous classes, leading to
reduces redundancy and development time as complex class hierarchies that can be
existing components can be leveraged. challenging to manage and understand.
Scalability: OOP allows for the modular Dependency Management: As the system
expansion of the system. New classes and grows, managing dependencies between
objects can be added with minimal impact on classes and objects becomes crucial.
existing code, making the system more Uncontrolled dependencies can lead to tight
scalable. coupling, making changes more difficult.
Maintenance Ease: Code organization through Testing and Debugging: In larger systems,
classes and encapsulation makes it easier to comprehensive testing becomes essential,
locate and modify specific functionalities, which can be time-consuming. Identifying
enhancing code maintainability. and debugging issues in a complex codebase
can be challenging.
In this code, we define an Animal class and two subclasses, Dog and Cat, each with a speak
method. Objects of these classes exhibit polymorphism as they respond differently to the same
method call.
Events: Events are occurrences that trigger the execution of specific code (event
handlers). Events can be generated by user interactions like mouse clicks or keyboard
inputs, system events like timer ticks or data arriving from a network, or even custom
events within the program.
Callbacks: Callbacks are functions or methods that are registered to be called when a
specific event occurs. They are a common mechanism for implementing event handlers.
Events:
Events represent occurrences or happenings within a program. They can be thought of as
signals or notifications that inform the program that something of interest has occurred. Here
are some common types of events:
User Interaction Events: These events are triggered by user actions, such as clicking a
button, pressing a key, moving the mouse cursor, or scrolling. For example, a button
click event occurs when a user clicks a button on a graphical user interface (GUI).
System Events: System events are generated by the underlying operating system or
runtime environment. They can include timer events, which occur at regular intervals,
network events like data arrival, or hardware events such as device connections or
disconnections.
Custom Events: In many programming environments, developers can define their own
custom events. These events are specific to the application and can be triggered based
on certain conditions or criteria within the program. For example, an application might
generate a custom event when a certain task is completed.
Triggering: When the event occurs (e.g., a button is clicked, a timer ticks, data arrives),
the event source detects it and triggers the associated event handler.
Execution: The event handler's code is executed in response to the event. This code can
perform various tasks, such as updating the user interface, processing data, or triggering
other actions within the program.
Completion: Once the event handler has completed its tasks, control is returned to the
program's main event loop, which continues to monitor and respond to other events.
Graphical User Interfaces (GUIs): Building interactive interfaces where user actions
(e.g., button clicks) trigger responses.
Web Development: Handling user interactions on web pages, such as clicking buttons,
submitting forms, or handling asynchronous requests.
Game Development: Managing game events like player input, collisions, and
animations.
Real-Time Systems: Reacting to external events like sensor inputs, network data, or
hardware events.
In event-driven programming, user interface (UI) design plays a crucial role. When evaluating
event-driven code, consider the following UI-related aspects:
UI Components: Identify the UI components used in the code, such as buttons, text fields,
labels, or graphical elements. Assess how they are created and configured.
Layout and Design: Evaluate the layout and design of the user interface. Is it user-
friendly, intuitive, and visually appealing? Ensure that components are appropriately
positioned and sized.
Feedback: Assess whether the user receives adequate feedback. Does the interface
provide informative messages or visual cues when actions are performed or errors occur?
Usability Testing: If possible, conduct usability testing to gather feedback from users.
Usability testing helps identify any usability issues and areas for improvement.
Initialize Form:
When the form is loaded, retrieve and display employee information based on the
provided employee ID.
Display a message if no data is found for the given ID.
Animate the display of the final calculated salary, starting from 0 and reaching the
calculated amount over a 3-second interval.
Update the displayed amount during the animation.
Change the color of the salary label at regular intervals from a predefined list of light
colors.
Supporting Methods:
Various supporting methods handle tasks such as fetching employee data from the
database, calculating daily pay rate, and rounding the calculated salary.
Update textboxes and labels with relevant information during different stages of the
salary calculation process.
GUI Elements:
Utilize textboxes, labels, and date pickers to interact with and display information to the
user.
Error Handling:
Implement basic error handling, notifying the user if invalid numeric values are entered
for attendance and overtime.
Visual Studio IDE stands as a robust and comprehensive integrated development environment,
offering a suite of tools and features to facilitate efficient software development. Developed by
Microsoft, Visual Studio caters to various programming languages, including C#, making it a
versatile choice for a wide range of developers.
Figure 27 Visual Studio 2022 Interface along with Grifindo Toys Project(authors work)
The IDE incorporates design tools for creating user interfaces, such as Windows Forms and
WPF applications. The drag-and-drop interface simplifies UI design, and the integrated XAML
editor provides fine-tuned control over the layout. Visual Studio also supports data-driven
application development, enabling seamless integration with databases.
Visual Studio's project management capabilities streamline the development lifecycle. The
solution explorer organizes project files, and the built-in version control facilitates
collaboration among team members. The inclusion of templates for different project types
expedites the creation of new applications, saving developers valuable time.
Employee Component
Used textboxes and input fields to capture employee details like name, ID, monthly
salary, overtime rates, and allowances.
Added options to view individual employee details, all employees' details, and a search
functionality.
Added User input fields or dropdowns for the admin to change parameters like date
range, salary cycle begin/end dates, and the number of leaves.
Salary Component
Added Textboxes for entering the number of leaves, absent days, holidays, and overtime
hours.
Added Textboxes and labels Display calculated values for No-pay, Base Pay, and Gross
Pay using labels or textboxes.
Included buttons to generate reports for monthly salary, overall salary summary, No-pay,
base pay, and gross pay for a specified month range.
In the Grifindo Toys system, employing separate classes for distinct components enhances code
organization, readability, and maintainability. Each class encapsulates a specific responsibility,
promoting a modular and efficient design.
The ID Generator class serves a crucial role in generating unique identifiers, ensuring data
integrity and avoiding conflicts within the system. In the context of Grifindo Toys, where
employee IDs are dynamically created, this class becomes instrumental. It provides a method to
generate IDs following a specific format, enhancing readability and systematic organization.
The ID Generator class encapsulates the logic for creating unique IDs. A method, perhaps named
GenerateEmployeeID(), could be implemented to generate employee IDs based on a specified
format. For instance, using a combination of static characters like "GT" and a dynamically
In the Grifindo Toys system, the ThemeChanger class contributes to a personalized user
experience. It allows users to customize the visual aesthetics of the application, aligning with
modern design principles or accommodating individual preferences. Themes play a vital role in
The TextAnimation class enhances the user interface of Grifindo Toys by providing smooth
text animations. This class encapsulates the logic for animating text changes, ensuring a
visually engaging experience for users. In the context of FormSalary, it is utilized to animate
the calculated salary display.
Database Design Principles are fundamental guidelines that help in creating well-organized and
efficient databases. These principles include:
Data Types Choosing the right data types for your columns
is crucial. It ensures efficient storage and
processing of data. For example, using integer
data types for whole numbers and date types
for date values.
In the context of database design for an Employee System, entities and their relationships play a
pivotal role. Entities, such as "Employee" and "EmployeeSalary," represent distinct objects,
while relationships define how these entities are interconnected. The "Employee" entity
captures crucial personal and professional details, acting as a foundational building block.
Simultaneously, the "EmployeeSalary" entity delves into financial aspects, creating a bridge to
the monetary dimension of an employee's engagement. The common identifier, "empid,"
The SQL table creation for Employee Information is thoughtfully designed, adhering to
principles of normalization and efficiency.
The "Employee" table incorporates key attributes such as "empid," "firstname," "lastname,"
"work," "mobile," "email," "address," "gender," and "age." The primary key, "empid," ensures
uniqueness, and each attribute is chosen to provide a comprehensive overview of an employee's
profile.
The inclusion of both personal and professional details aligns with the principles of effective
database organization.
The SQL table creation for Salary Information, encapsulated in the "EmployeeSalary" table,
meticulously captures the financial aspects of an employee's engagement. Similar to the
Employee Information table, the "empid" serves as the primary key, establishing a link between
the two tables.
The use of the "DECIMAL" data type for monetary values ensures accuracy in representation,
especially in scenarios where precision is crucial.
Efficient code editing and autocompletion are integral aspects of a developer's toolkit. A robust
code editor enhances productivity by providing features such as syntax highlighting, code
folding, and autocompletion.
These tools assist developers in writing clean and error-free code. Autocompletion anticipates
the developer's intent, offering suggestions for functions, variables, and even entire code
snippets. This feature accelerates the coding process and reduces the likelihood of errors.
Debugging tools are the backbone of a developer's ability to identify and resolve issues within
their code. These tools provide a comprehensive set of features, including breakpoints, variable
inspection, and step-by-step execution.
Breakpoints allow developers to pause the execution of their code at specific points, enabling in-
depth examination of variables and program flow. Debugging tools also facilitate the
identification of runtime errors and help developers understand the behavior of their code in real-
time.
The integration of robust debugging tools is crucial for maintaining code quality and ensuring
the reliability of software applications.
Graphical User Interface (GUI) design and form building tools empower developers to create
visually appealing and user-friendly applications. These tools often include drag-and-drop
functionality, allowing developers to design interfaces without delving deeply into code.
Form-building features simplify the creation of input forms, enabling developers to collect user
data seamlessly.
A well-integrated GUI design environment enhances the user experience and accelerates the
development of applications with intuitive interfaces.
Visual Studio stands out as a premier Integrated Development Environment (IDE) for
application development, offering a plethora of advantages.
One key benefit is its comprehensive set of tools that cater to diverse programming languages,
making it a versatile choice for developers.
The IDE's intelligent code completion and suggestion features significantly enhance
productivity, enabling developers to write code more efficiently.
Visual Studio's extensive library of extensions further amplifies its capabilities, allowing
developers to customize their environment based on specific project requirements.
Additionally, the seamless integration with various third-party services and platforms simplifies
tasks such as version control, deployment, and testing.
Efficiency in coding and debugging is a hallmark of Visual Studio's capabilities. The IDE
provides an intuitive and user-friendly interface, streamlining the coding process.
Its robust code editor supports features like syntax highlighting, auto-indentation, and real-time
error checking, contributing to clean and error-free code development.
The integrated debugging tools offer a powerful set of features, including breakpoints, step-by-
step execution, and variable inspection. This not only simplifies the identification and
resolution of issues but also facilitates a deeper understanding of code behavior during runtime.
Visual Studio's emphasis on efficiency makes it a go-to choose for developers aiming to
optimize their workflow. Efficiency in coding and debugging is a hallmark of Visual Studio's
capabilities.
The IDE provides an intuitive and user-friendly interface, streamlining the coding process. Its
robust code editor supports features like syntax highlighting, auto-indentation, and real-time
error checking, contributing to clean and error-free code development.
The integrated debugging tools offer a powerful set of features, including breakpoints, step-by-
step execution, and variable inspection.
This not only simplifies the identification and resolution of issues but also facilitates a deeper
understanding of code behavior during runtime.
Visual Studio's emphasis on efficiency makes it a go-to choose for developers aiming to
optimize their workflow.
Visual Studio's seamless integration with the .NET Framework is a pivotal advantage for
developers working within the Microsoft ecosystem.
The IDE provides robust support for developing applications using various .NET technologies,
including ASP.NET for web development, Windows Forms for desktop applications, and
Xamarin for cross-platform mobile development.
This integration ensures that developers can leverage the full power of the .NET Framework,
accessing a rich set of libraries and tools to expedite application development.
Visual Studio's compatibility with the latest .NET releases underscores its commitment to
staying abreast of technological advancements.
The loading screen serves as the first impression of the Grifindo Toys Payroll System,
contributing to a seamless user experience. Its purpose extends beyond functionality,
incorporating a visual appeal that ensures users feel engaged during the initial loading process.
This screen displays key company details, including the Grifindo Toys logo, a slogan capturing
the company's ethos, and possibly a brief mission statement. These elements not only introduce
users to the brand but also set a professional and welcoming tone for the entire application.
The login form is meticulously designed with modern aesthetics and a user-friendly layout. Its
sleek design incorporates intuitive input fields, contributing to an overall pleasant visual
experience.
Security is a paramount concern, and the system employs robust measures such as password
encryption to safeguard user credentials. The inclusion of a "Forgot Password" option enhances
security further. This feature triggers a secure process, users can securely reset their passwords
in case of any security concerns or forgotten credentials.
This holistic approach to design and security establishes a foundation for a reliable and user-
centric authentication process.
.
At the core of the application, the main form serves as the central hub for navigation, offering a
seamless and intuitive user experience.
Structurally, it houses various child forms accessible through a thoughtfully organized menu.
The menu contains logically placed buttons corresponding to different components of the
Grifindo Toys Payroll System.
These buttons facilitate easy navigation between essential features such as Home, Employee,
Basic Salary, Settings, Salary, and View. Clicking on each button dynamically loads the
respective child form within the main form, ensuring a cohesive and user-friendly interaction
with the entire application.
The Home Form is the user's initial point of interaction, providing a personalized and
informative welcome. It dynamically greets the logged-in user, creating a sense of familiarity.
This form often includes important announcements or updates related to the payroll system,
ensuring that users are promptly informed of any critical information. Additionally, Home Form
acts as a launching pad, offering quick links or buttons that provide easy access to frequently
used features.
By combining personalized greetings, important updates, and convenient shortcuts, the Home
Form establishes itself as an efficient and welcoming starting point within the Grifindo Toys
Payroll System.
The Employee Form encompasses a comprehensive set of functionalities that empower the
system administrator.
This form allows the admin to efficiently register new employees, capturing crucial details such
as monthly salary, overtime rates, and allowances. Additionally, the system offers robust
capabilities for updating and deleting employee details, ensuring that the database remains
accurate and up to date.
A powerful search functionality further streamlines the admin's tasks, enabling quick and
efficient retrieval of specific employee records based on various criteria.
Altogether, the Employee Form stands as a vital component, providing the necessary tools for
effective employee management within the payroll system.
The Basic Salary Form represents the core of the salary calculation component within the
Grifindo Toys Payroll System. Its features are designed to facilitate precise salary calculations,
ensuring accuracy and fairness in remuneration.
Admin users input the date range for which salaries are to be calculated, defining the scope of
the salary cycle. The form also accommodates the recording of leaves, absent days, holidays,
and overtime hours, crucial elements for determining the base pay.
Complex algorithms and formulas are applied to calculate the base pay value, taking into
account the monthly salary, allowances, and overtime rates. This form, therefore, serves as a
critical interface for administrators to orchestrate precise and transparent salary computations.
The Settings Form plays a pivotal role in providing administrators with the flexibility to tailor
the Grifindo Toys Payroll System according to specific organizational requirements. This
component allows the admin to finetune parameters essential for accurate salary calculations.
Key configurable elements include the date range for a salary cycle, providing flexibility in
aligning the system with the company's unique payroll structure. The admin can set the salary
cycle's beginning and end dates, ensuring synchronization with organizational policies.
Furthermore, the Settings Form facilitates the adjustment of critical factors such as the number
of leaves an employee is entitled to within a given year. In essence, the Settings Form
empowers administrators with the tools needed to customize the payroll system to meet the
specific needs of Grifindo Toys.
The Salary Form represents the pinnacle of the Grifindo Toys Payroll System's functionality,
where intricate salary calculations are executed with precision.
This form orchestrates a multi-step process, involving the calculation of base pay,
determination of no-pay values in case of absenteeism, and the ultimate calculation of gross
pay. The base pay is derived from a complex formula considering monthly salary, allowances,
and overtime rates. Simultaneously, the system calculates the no-pay value if an employee has
been absent, ensuring fairness in remuneration.
The gross pay, the final outcome, is then determined by subtracting the sum of no-pay value
and government tax rates from the base pay. The calculated values, including no-pay, base pay,
and gross pay, are meticulously recorded in the database, forming a comprehensive record for
each employee for every month.
The View Form acts as the analytical powerhouse of the Grifindo Toys Payroll System,
providing administrators with powerful tools for generating insightful reports. This form
enables the generation of detailed reports, including monthly salary reports for individual
employees and overall salary summaries spanning multiple months.
This holistic reporting functionality ensures that administrators can gain valuable insights into
the payroll data, facilitating informed decision-making and strategic planning for the
organization's financial management.
Breakpoints allow developers to pause the execution of the code at a specific line,
Setting providing a snapshot of the program's state. By strategically placing breakpoints,
Breakpoint developers can inspect variables, identify potential security vulnerabilities, and ensure
the robustness of the application by understanding its behavior at critical points.
Visual Studio allows developers to inspect variables and values during runtime. This
Inspecting feature is invaluable for identifying unexpected behaviors, ensuring that variables
Variables contain the expected values, and mitigating security risks related to data manipulation
and Values or injection.
These windows in Visual Studio enable developers to monitor specific variables and
Watch and expressions. By using the Watch and Immediate windows, developers can evaluate
Immediate the correctness of code logic, identify potential security threats related to variable
Windows manipulation, and enhance the overall robustness of the application.
Role in Security and Robustness: Visual Studio provides robust exception handling
Exception features, allowing developers to catch and handle exceptions during debugging. By
Handling: examining exception details, developers can identify potential security risks and
Exception implement proper error handling mechanisms, enhancing the overall security and
Handling robustness of the application.
The Call Stack window in Visual Studio displays the sequence of method calls
leading to the current point in the code. This is crucial for understanding the
program's flow and identifying potential security vulnerabilities related to unexpected
method invocations or stack-related issues, contributing to a more robust application.
Debugging played a critical role in uncovering potential security vulnerabilities within the
application. For instance, during the debugging process, breakpoints and variable inspection
revealed instances where user input lacked proper validation or sanitization.
Below Images Showcase the Error Encountered, But Was able to Fix after Debugging.
The debugging process facilitated the tracing of the application's flow, revealing areas
susceptible to unauthorized code execution. By leveraging debugging features, specific instances
were identified and subsequently addressed, fortifying the application against potential security
risks.
Below Example Image Shows a Error faced and How Visual Studio Debugging Process Showed
the Error and Potential Fixes.
Exception handling mechanisms were thoroughly tested and refined during the debugging
process. Instances where exceptions were discovered and handled appropriately were explored.
The debugging process contributed to robust exception handling, preventing potential security
breaches.
The debugging process has proven instrumental in fortifying the security and robustness of the
application. The iterative nature of debugging, coupled with continuous improvement in
response to findings, has contributed to the development of a reliable and secure software
application.
In the constructor, an array of loading texts is defined to provide dynamic messages during the
loading process. The InitializeTimer method sets up a timer, and the form is configured for a
borderless appearance, double buffering, and resizing.
RapidLabelUpdate cycles through loading texts for two labels, updating them with a red color.
The method uses BeginInvoke to update the UI on the main thread, ensuring thread safety.
Label indices are incremented to display different texts in subsequent calls
OnPaint, PictureBox1_Paint, and panel1_Paint methods handle drawing rounded edges for the
form, picture box, and panel, respectively. GraphicsPath is utilized to create a path with
rounded corners, and Region is set to apply the rounded shape. These methods contribute to a
visually appealing and modern user interface.
This part defines two constants for a hardcoded valid username and password.
PerformLogin method checks if the entered username and password match the valid credentials.
If valid, it opens the FormMainMenu. If not, it displays error messages and clears the respective
textboxes.
The SelectThemeColor method is responsible for choosing a random color from a predefined list
to be used as the theme color for buttons and panels. It employs a simple randomization
technique, ensuring that the same color is not selected consecutively to enhance visual variety.
This function is crucial for providing a visually appealing and diverse user interface.
In the ActivateButton method, a button is dynamically styled when clicked. It changes the
button's background color, text color, font, and also adjusts the theme colors of the title bar and
logo panel. This function not only enhances the visual feedback for the user but also ensures a
consistent and aesthetically pleasing appearance in line with the chosen theme.
DisableButton is a utility method that resets the appearance of all buttons in the menu,
deactivating them. This function is called before activating a new button, ensuring that only the
clicked button stands out visually. Consistent styling is maintained, contributing to a coherent
and user-friendly interface.
OpenChildForm is a versatile method used for displaying child forms within the main form. It
handles the closure of any existing child form, activates the corresponding button, sets up the
properties of the child form for display, and updates the title label. This method centralizes the
logic for opening child forms, promoting code reuse and maintainability.
The timer1_Tick method is triggered periodically by a timer. It updates a label (label5) with the
current time in the format "HH:mm:ss". This real-time clock feature adds a dynamic element to
the form, providing users with up-to-date information. The timer enhances the user experience
by offering a continuously updated display of the current time.
Random ID Generator
This method generates a random employee ID in the format "GTXXX," where XXX is a three-
digit number. The generated ID is displayed in the empid TextBox.
This method is triggered when the "Generate Summary" button is clicked. It collects input from
textboxes and date pickers, calls the GenerateSalarySummary method, and displays the
generated salary summary in the SummaryTextBox.
This method is triggered when the "Set Default Info" button is clicked. It sets default values for
the date range, salary cycle begin date, salary cycle end date, and leaves, providing a
convenient way to reset the form to predefined settings.
Get info
This method is triggered when the "Get Info" button is clicked. It retrieves employee
information from the database based on the provided employee ID (empID). If data is found, it
updates various textboxes and date pickers with relevant information.
This is a custom method (CalculateSalary) where you can implement your logic to calculate the
salary based on the provided dates attended, OT hours, and other relevant information.
Coding standards play a pivotal role in shaping the landscape of software development,
impacting both teams and individual developers.
From enhancing code readability to fostering collaborative efficiency and minimizing errors,
the discussion will explore how coding standards contribute to the overall success and
sustainability of software projects.
Team Individual
Onboarding and Training: New team members can For an individual developer,
quickly adapt to the project adhering to a coding standard
environment when there is a aid in self-learning and skill
coding standard in place. It development. It becomes a
expedites the onboarding guide for writing better code
process and facilitates and learning from established
knowledge transfer. practices.
Algorithms - https://www.khanacademy.org/computing/computer-science/algorithms