0% found this document useful (0 votes)
4 views81 pages

Asm2 Pro

This document is an assignment front sheet for a BTEC Level 5 HND Diploma in Computing, focusing on programming paradigms such as procedural, object-oriented, and event-driven programming. It includes sections on definitions, features, code structure, and advantages/disadvantages of each paradigm, along with a comparison and examples. The report aims to identify the optimal programming approach for a water billing system, emphasizing security and efficiency.

Uploaded by

thangphamchien09
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)
4 views81 pages

Asm2 Pro

This document is an assignment front sheet for a BTEC Level 5 HND Diploma in Computing, focusing on programming paradigms such as procedural, object-oriented, and event-driven programming. It includes sections on definitions, features, code structure, and advantages/disadvantages of each paradigm, along with a comparison and examples. The report aims to identify the optimal programming approach for a water billing system, emphasizing security and efficiency.

Uploaded by

thangphamchien09
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/ 81

ASSIGNMENT 2 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 1: Programming

Submission date Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Pham Chien Thang Student ID BH01999

Class SE07103 Assessor name Nguyen Thi Hong Hanh

Student declaration

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’s signature Thang

Grading grid
P3 P4 P5 P6 M2 M3 M4 D2 D3 D4

1
 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date:


Lecturer Signature:

3
Contents
I. Introduction.............................................................................................................................................. 7
II. What is procedural, object-orientated and event-driven?.......................................................................7
1. Procedural Programming....................................................................................................................... 7
a) Definition.......................................................................................................................................... 7
b) Features........................................................................................................................................... 7
c) Code structure..................................................................................................................................8
d) Flow of code.....................................................................................................................................8
e) Readability and Maintainability....................................................................................................... 8
f) Limitations........................................................................................................................................ 8
g) Advantages and Disadvantages........................................................................................................9
2. Object-Oriented Programing (OOP)..................................................................................................... 10
a) Definition........................................................................................................................................ 10
b) Features......................................................................................................................................... 10
c) Code structure................................................................................................................................10
d) Flow of code...................................................................................................................................10
e) Readability and Maintainability..................................................................................................... 11
f) Limitations...................................................................................................................................... 11
g) Advantages and Disadvantages......................................................................................................11
3. Event-Driven Programing (EDP)............................................................................................................12
a) Definition........................................................................................................................................ 12
b) Features......................................................................................................................................... 12
c) Code structure................................................................................................................................13
d) Flow of code...................................................................................................................................13
e) Readability and Maintainability..................................................................................................... 13
f) Limitations...................................................................................................................................... 14

4
g) Advantages and Disadvantages.......................................................................................................14
III. Relationship between procedural, object-oriented, event driven.........................................................15
IV. Program flowchart.................................................................................................................................16
1. Login.................................................................................................................................................... 16
2. Add Customer to database..................................................................................................................17
3. Remove Customer from database.......................................................................................................18
4. Update Customer information............................................................................................................ 19
XI. PP, OOP and EDP examples through a simple code...............................................................................20
XII. Comparing PP, OOP, EDP...................................................................................................................... 20
XIII. Debugging and how it can be used to help develop more secure, robust applications......................21
XIV. References...........................................................................................................................................22

Figure 1: Function:
Login ..............................................................................................................................16
Figure 2: Function: Add customer ................................................................................................................
17 Figure 3: Function: Remove
customer ......................................................................................................... 18 Figure 4: Function: Update
customer data .................................................................................................. 19 Figure 5: Example:
Relationship between programming types ................................................................... 20

5
Table 1: PP, OOP and
EDP ............................................................................................................................21

6
I. Introduction
- C#, pronounced "C-Sharp", is a modern, object-oriented programming language designed by
Microsoft for the .NET Framework. C# offers a balance between ease of use and power, making it
popular for building a wide range of applications. Its object-oriented approach allows developers
to create well-structured, reusable code, while its type safety ensures program stability. With a
large community and extensive libraries, C# is a versatile tool for programmers of all levels.
- This report explores various programming paradigms and their suitability for this application. By
examining the advantages and disadvantages of different language approaches, we aim to identify
the optimal paradigm that fosters both security and efficiency for our water billing system,
replaces the less secure and difficult to use of console version.

II. What is procedural, object-orientated and event-driven?

1. Procedural Programming

a) Definition
o In procedural programming, you solve problems by breaking them down into step-by-step
instructions grouped into procedures (functions). This promotes code reuse and
organization. Think of it as a recipe with clear steps – instructions are followed
sequentially to achieve a result.

b) Features
o Sequential execution: Instructions follow a clear order. o Modularity: Functions group
related code for better organization. o Data structures: Built-in structures manage data
efficiently. o Abstraction: Procedures hide complex details, focusing on functionality. o
Control flow: Control statements guide program execution with decisions and loops.

7
c) Code structure
o Main Function: Program's starting point, calling other functions.
o Functions: Reusable code blocks for specific tasks. o Control Flow:
Statements (if/else, loops) guide execution order.

d) Flow of code
o Procedural code flows step-by-step. The program starts in the main function, which calls
smaller, reusable functions to complete tasks. These functions execute instructions
sequentially, with control flow statements (if/else, loops) guiding the order based on
conditions. Functions can receive data (parameters) and return results, allowing them to
work together and build upon each other's work.

e) Readability and Maintainability


- Procedural programming fosters code readability and maintainability through several key aspects:
o Modularization: By breaking down complex problems into smaller, well-defined functions,
procedural code becomes easier to understand and follow.
o Focus on Functionality: Functions promote a focus on functionality, allowing developers to
concentrate on the "what" rather than the intricate details of the "how." This improves
code readability as the core logic becomes more explicit.
o Code Reuse: Procedural programming encourages code reuse through functions. This
reduces redundancy and simplifies maintenance, as changes only need to be made in one
location (the function) to impact the entire program.
- However, for very large or intricate systems, procedural programming can encounter limitations in
readability and maintainability:
o Spaghetti Code: In complex projects, extensive reliance on procedural techniques can lead
to "spaghetti code," where numerous functions interact in a tangled mess, making it
difficult to understand the overall program flow.
o Global Variables: Excessive use of global variables can create dependencies across the

entire program, making it challenging to track changes and potential side effects.

8
f) Limitations
o Reusability: Procedural programs tend to have repetitive code. If you need the same
functionality in multiple places, you often have to rewrite it, making the code harder to
maintain and update.
o Data focus: Procedural programming prioritizes the steps (procedures) to take rather than
the data itself. This can make it difficult to model complex systems where data is
important.
o Real-world modeling: Procedural code doesn't map well to real-world entities. Imagine a
program representing a car. In procedural programming, you might have separate
functions for accelerating, braking, and turning. Object-oriented programming, on the
other hand, would create a "Car" object that encapsulates these behaviors.
o Complexity: Procedural code can become cumbersome and hard to manage in large
projects. As the program grows, keeping track of all the functions and their interactions
becomes a challenge.

g) Advantages and Disadvantages


o Advantages:
▪ Simplicity: Procedural code is easy to understand and write, especially for
beginners. The logic is straightforward, following a step-by-step approach.
▪ Modularization: Breaking down complex problems into smaller, manageable
functions promotes better code organization and readability.
▪ Efficiency: Procedural languages can be very efficient, particularly for well-defined
tasks. The focus on clear instructions can lead to optimized code.
▪ General-purpose: Procedural programming is applicable to a wide range of
problems, making it a versatile tool for programmers.
o Disadvantages:
▪ Reusability: Code reuse can be difficult. Procedural programs often have repetitive
blocks of code that need to be rewritten if needed in multiple places.
▪ Maintainability: Large procedural programs can become hard to maintain as the
complexity grows. Keeping track of numerous functions and their interactions can
be challenging.

9
▪ Data Organization: Procedural programming prioritizes the procedures themselves
over the data they operate on. This can make it difficult to model complex systems
where data plays a central role.
▪ Real-world Modeling: Representing real-world entities with procedural code can
be cumbersome. For instance, a car simulation might have separate functions for
acceleration, braking, and steering. Object-oriented programming offers a more
natural way to model such scenarios.
2. Object-Oriented Programing (OOP)

a) Definition
o In Object-oriented programming (OOP), you build programs with "objects" that act like real-
world things. These objects bundle data and the functions that use that data. OOP keeps
your code organized and secure by focusing on modularity (reusable pieces) and
encapsulation (hiding an object's inner workings).

b) Features
o Objects (based on Classes): Imagine a car blueprint (class) defining features (data) and
actions (methods) for all cars (objects).
o Inheritance: Lets new classes inherit traits from existing ones. Race cars can inherit from
cars and add a boost function.
o Encapsulation: Bundles an object's data and methods, protecting it from unauthorized
changes.
o Polymorphism: Allows objects to respond differently to the same message. A car and
bicycle handle "drive" differently.

c) Code structure
o Classes: Blueprints defining data (properties) and actions (methods) for objects.
o Objects: Instances of classes holding specific data and performing actions defined in the
class.
o Inheritance: Reusing code by creating new classes based on existing ones. o
Encapsulation: Controlling access to an object's data for better security.

10
d) Flow of code
- OOP doesn't have a single, rigid flow of code like a traditional top-down script. Instead, it focuses
on interactions between objects. Here's how OOP code typically flows:
o Object Creation: You define classes with properties and methods. Then, you create objects
(instances) of those classes.
o Method Calls: Objects interact by sending messages (method calls) to each other. These
methods access and manipulate the object's data (properties). o Conditional Logic: Within
methods, you can use conditional statements (if/else) and loops to control the flow of
execution based on specific conditions.
o Inheritance: If classes inherit from others, the child class's methods might call inherited
methods from the parent class. This creates a flow where specific behaviors are reused
and potentially overridden.

e) Readability and Maintainability


o Modularization: Code is broken down into objects, each handling specific tasks. This
makes the code easier to understand because you can focus on one object at a time.
o Encapsulation: Objects bundle data (properties) and the functions (methods) that use that
data. This keeps the code clean and hides complexity by protecting internal workings.
o Real-world mapping: OOP lets you model your code with objects that resemble real-world
things. This makes the code more intuitive and easier to reason about.

f) Limitations
o Complexity: OOP can lead to more complex code, especially in large projects. The
emphasis on classes, inheritance, and relationships between objects can make it harder to
understand the overall program flow.
o Overhead: OOP code can be larger than procedural code due to the extra structure of
classes and objects. This can sometimes impact performance, especially for very
resourceconstrained systems.
o Over-engineering: Sometimes, problems can be solved more simply without all the
structure of OOP. OOP might not be the best choice for every situation.
o Debugging Challenges: Complex dependencies between objects can make debugging
trickier. Changes in one object might ripple through others, making it harder to pinpoint
the source of an issue.

11
g) Advantages and Disadvantages
o Advantages:
▪ Reusability: OOP allows you to create reusable code components (objects and
classes). This saves time and effort in future projects.
▪ Modularity: Code is broken down into manageable objects, making it easier to
understand, maintain, and modify.
▪ Encapsulation: Objects bundle data and methods, protecting data integrity and
hiding internal complexity.
▪ Inheritance: New classes can inherit properties and methods from existing ones,
promoting code reuse and extensibility.
▪ Real-world mapping: OOP lets you model code with objects that resemble
realworld things, making it more intuitive.
o Disadvantage:
▪ Difficult for beginners: OOP concepts like classes, inheritance, and polymorphism
can be challenging for beginners to grasp.
▪ Complexity: Large OOP projects can become complex due to intricate object
relationships and potential over-engineering.
▪ Performance overhead: OOP code can be larger and slower than procedural code
due to the extra structure. (Not always a significant concern)
▪ Debugging challenges: Dependencies between objects can make debugging
intricate. Issues in one object might affect others.
▪ Not ideal for all problems: Sometimes, simpler programming paradigms might be
better suited for specific tasks.

3. Event-Driven Programing (EDP)

a) Definition
o In event-driven programming, the program waits for events (user clicks, system changes)
and reacts with specific code. This flexible approach is ideal for GUIs and network
applications

12
b) Features
o Event-driven architecture: Programs are structured around handling asynchronous events
(user interactions, system messages) that trigger specific handler functions. This modular
approach promotes loose coupling and maintainability.
o Event loop: A central mechanism continuously monitors for incoming events and
efficiently dispatches them to the appropriate event handlers. This ensures timely
processing and responsiveness.
o Event handlers: Dedicated functions encapsulate the logic for handling specific events.
This promotes code reusability and simplifies maintenance.
o Asynchronous and non-blocking execution: Event-driven programs avoid blocking the
main thread while waiting for tasks to complete. This allows for a more responsive user
experience and efficient handling of concurrent operations.
c) Code structure
o Define Events: Specify what can happen (clicks, messages, timers).
o Register Listeners: Components say what events they care about and how to respond
(handler functions).
o Event Loop: The program waits for events to be triggered.
o Dispatch & Handle: Events are matched to listeners, and their handler functions are
executed.

d) Flow of code
o Initialization: The program sets up the event loop, which continuously monitors for
incoming events.
o Component Registration: Different parts of the program (buttons, windows, network
connections) register themselves with the event loop, specifying the events they're
interested in (clicks, messages, etc.) and the corresponding handler functions to be called.
o Event Loop: The program enters a waiting state, constantly checking for events.
o Event Trigger: When an event occurs (user clicks a button, network data arrives), it's sent
to the event loop.
o Event Dispatch: The event loop matches the triggered event with the previously registered
components.

13
o Handler Execution: The event loop triggers the corresponding handler function associated
with the specific event and component. This handler function contains the code that
actually responds to the event (processing user input, updating the UI, etc.).
o Return to Loop: After the handler function finishes, control returns to the event loop, and
the cycle continues, waiting for the next event.

e) Readability and Maintainability


o Modular Code: EDP breaks down functionality into discrete event handlers, focusing on
specific actions. This improves code clarity by keeping logic focused and organized.
o Loose Coupling: Components only need to register for events they care about, minimizing
dependencies. This reduces the ripple effect of changes, making code easier to understand
and modify.
o Focus on Events: The code revolves around handling well-defined events, making the
program's purpose and flow more explicit. This improves readability for developers
understanding how the system reacts to different stimuli.
o Event Handlers as Documentation: Well-named handler functions act as self-documenting
units, explaining how specific events are handled. This reduces the need for extensive
comments, improving code clarity. o Testability: Isolated event handlers are easier to unit
test, promoting code quality and maintainability in the long run.

f) Limitations
o Complexity: Reasoning about program flow can be trickier due to asynchronous events
and potential interactions.
o Debugging: Traditional techniques are less effective due to unpredictable event timing.
o Event Ordering: Ensuring proper event sequence might require additional design and
techniques.
o Error Handling: Error propagation through the system needs careful consideration. o
Over-engineering Risk: EDP's flexibility can lead to overly complex code for simple tasks.

g) Advantages and Disadvantages


- Advantages:

14
o Responsiveness: EDP excels at creating highly responsive applications. Programs don't
block waiting for tasks, allowing them to react quickly to user interactions and system
events. This is ideal for user interfaces (UIs) and network applications.
o Scalability: The loosely coupled nature of EDP makes it easy to scale applications.
Components can be added or removed independently without affecting others, simplifying
horizontal and vertical scaling to meet changing demands.
o Maintainability: EDP promotes well-organized code. Breaking down functionality into
focused event handlers improves readability and simplifies maintenance by minimizing
dependencies between parts of the program.
o Efficiency: EDP avoids unnecessary resource consumption by eliminating continuous
polling for updates. Events trigger actions only when necessary, making applications more
efficient.
- Disadvantages:
o Complexity: Reasoning about program flow in EDP can be more challenging due to the
asynchronous nature of events and potential interactions between components. This
requires careful design to avoid unintended behavior.
o Debugging: Debugging EDP can be trickier than traditional linear code. The unpredictable
timing of events makes it harder to pinpoint the root cause of issues. Debuggers and
logging become even more crucial.
o Over-engineering: The flexibility of EDP can be a double-edged sword. It's easy to
overengineer simple tasks by introducing unnecessary event-driven architecture where a
simpler approach would suffice.

III. Relationship between procedural, object-oriented, event driven


- Procedural Programming: The foundation. It focuses on breaking down tasks into step-by-step
instructions (functions).
- Object-Oriented Programming (OOP): Builds upon procedures. It organizes code around objects
(data and related functions) that represent real-world entities. OOP promotes modularity and
reusability.
- Event-Driven Programming (EDP): A way to structure applications. It focuses on handling events
(user clicks, system messages) and reacting with specific code. EDP excels at responsiveness and
can be used within both procedural and object-oriented paradigms.

15
In essence, OOP provides a way to organize code, while EDP dictates a program's flow in response to
events. OOP often complements EDP because objects can neatly encapsulate event handling logic.
They aren't mutually exclusive concepts; developers can leverage all three approaches to build
wellstructured and responsive software.

IV. Program flowchart

1. Login

Figure 1: Function: Login

16
2. Add Customer to database

Figure 2: Function: Add customer

17
3. Remove Customer from database

Figure 3: Function: Remove customer

18
4. Update Customer information

Figure 4: Function: Update customer data

19
XI. PP, OOP and EDP examples through a simple code

Figure 5: Example: Relationship between programming types

- Through the simple code above, we can understand the basic operations of PP, OOP and EDP and
their relationship in programming.

XII. Comparing PP, OOP, EDP


Feature Procedural Object-Oriented Event-Driven
Programming (PP) Programming (OOP) Programming (EDP)

Focus Functions and Objects and classes Events and message


procedures passing

Data Global or passed as Encapsulated within Can be in objects or


arguments objects separate

Code Modular but not More organized and Highly responsive and
wellorganized reusable asynchronous

Communication Function calls Method calls on objects Event handlers or listeners

20
State Difficult to manage Easier to manage with More complex due to
Management encapsulation asynchronous

Inheritance Not directly supported Supported for code reuse Not directly applicable
Table 1: PP, OOP and EDP

XIII. Debugging and how it can be used to help develop more secure,
robust applications.
- Identifying and Fixing Vulnerabilities:
o Logic Errors: Bugs in code logic can create security holes. Debugging helps uncover these
errors, like unintended data access or incorrect validation.
o Memory Leaks: Improper memory management can lead to vulnerabilities like buffer
overflows, where attackers overwrite memory to gain control. Debugging tools can detect
memory leaks and help prevent such vulnerabilities.
o Injection Attacks: Errors in user input handling can allow attackers to inject malicious code
(SQL injection, XSS). Debugging helps verify that input is properly sanitized and validated.
- Enhancing Robustness:
o Crash Prevention: Unhandled exceptions can crash applications. Debugging helps identify
potential causes of crashes and implement error handling mechanisms to make
applications more resilient.
o Resource Leaks: Leaving resources like files or database connections open can cause
performance issues and instability. Debugging can help identify resource leaks and ensure
proper cleanup.
o Unexpected Behavior: Debugging helps uncover unexpected behavior that might not be
immediately apparent. This allows developers to fix these issues and create more
predictable applications.
- Benefit of effective debugging:
o Reduces Security Risks: Eliminates vulnerabilities that could be exploited by attackers. o
Improves Stability: Makes applications less prone to crashes and unforeseen issues. o
Enhances Performance: Helps identify and fix performance bottlenecks.
o Increases Maintainability: Well-debugged code is easier to understand and modify in the
future.

21
XIV. References
My source code on Github:

- HuyMaster (2024). HuyMaster/Assignment2. [online] GitHub. Available at:


https://github.com/HuyMaster/Assignment2 [Accessed 8 Apr. 2024].

22
V. Tools used for application development
• Programming language: C#
• IDE: Visual Studio 2022
VI. Application creating
1. Create project
• I use Windows Forms App template to be able to design forms
2. Set project name
• I named the project Assignment2
3. Set project framework
• I use .NET 8.0 for my project
VII. Application classes
1. Program.cs
• This class is entry point (main class) of my application.
• The program will first call the Configure() method, which will add two Account objects to ActiveAccounts in the
ProgramEnvironment class.
• The program will then call ShowBaseForm(), which will open the LoginForm.


2. DLLIntermediate.cs
• This class mediates my program with the Windows DLLs (Dynamic Link Library). Here are kernel32.dll and
user32.dll.
• This class imports GetConsoleWindow() method from
kernel32.dll and ShowWindow(IntPtr, int) from
user32.dll.
• In addition, this also add a method similar to
ShowWindow(IntPtr, int) but change the IntPtr type
parameter to Form so that we can use the
ShowWindow method directly from the provided Form.

3. utils/Log.cs (part
1)
• Provides methods for logging, helpful in testing and debugging
3. utils/Log.cs (part
2)
• Provides methods for logging, helpful in testing and
debugging

Example log at console:


4. core/ProgramEnvironment.cs

• Provide global content for the application


5. core/SystemColor.cs
• Used to get the accent color from the system to provide events
to listeners when the system changes color (usual the color
change comes from changing the system background image)
6. data/DataProvider.cs
• Interfaces for common data types in this application
7. data/Database.cs
(part 1)
• Database for data, data class must be inherited from IData<T>
and have an IMinimalData<T> inherited class of itself
• The class provides Add and Remove() methods used to add and
delete data from the Database, it also provides private Save()
and Load() methods, called when data changes to store data to
file

7. data/Database.cs
(part 2)
• Database for data, data class must be inherited from IData<T>
and have an IMinimalData<T> inherited class of itself
• The class provides Add and Remove() methods used to add
and delete data from the Database, it also provides private
Save() and Load() methods, called when data changes to store
data to file

8. data/Account.cs
• Account object use to login in LoginForm
9. data/Customer.cs (part 1)
• Customer object. Store data of customer, contains
CustomerType, calculation methods
9. data/Customer.cs (part 3)
• Customer object. Store data of customer, contains
CustomerType, calculation methods
9. data/Customer.cs (part 4)
• Customer object. Store data of customer, contains
CustomerType, calculation methods
9. data/Customer.cs (part 5)
• Customer object. Store data of customer, contains CustomerType, calculation methods
10. gui/BaseForm.cs
• Frames of other forms in the application, initialized
basic properties
• The code in InitializeComponent() is minified because
it’s too wordy and unnecessary to show, these codes
simply set the properties of Controls

11. gui/About.cs
• Information about application
12. gui/LoginForm.cs
• The window appears when starting the application. Used to verify
users.
• Like BaseForm, InitializeComponent() is also minified.
• Once the entered information is valid, go to MainForm
13. gui/MainForm.cs (part 1)
• Actions Add, Delete, Update, View detailed user
information here
13. gui/MainForm.cs (part 2)
• Actions Add, Delete, Update, View detailed user
information here
13. gui/MainForm.cs (part 3)
• Actions Add, Delete, Update, View detailed user information here
13. gui/MainForm.cs (part 4)
• Actions Add, Delete, Update, View detailed user
information here
13. gui/MainForm.cs (part 5)
• Actions Add, Delete, Update, View detailed user
information here
13. gui/MainForm.cs (part 6)
• Actions Add, Delete, Update, View detailed user information
here
14. gui/UserDetailsForm.cs (part 1)
• Used to display all information about the
Customer and the print action
14. gui/UserDetailsForm.cs (part 2)
• Used to display all information about the
Customer and the print action
VIII.Testing
At Login Form
1.
• This is the interface of LoginForm
• I will use some weird usernames and passwords
• And as expected, the application prevented the greedy hacker
from breaking into the application and editing his used water
down.
2. At Login Form
• So how to log into the application? Well, just log in with the
username admin and the password also admin. Or you can
use huymaster as your login username and don't need to
enter an annoying password
• Just in time, my wallpaper just changed to another image
because I set the wallpaper as a slideshow, we can see the
background of the program has changed color.
• This is the interface of MainForm:
2. At Login Form
• It's so empty, try adding something.
• What if I don't enter anything, will the program add air to the
table?

• It seems the programmer has already considered the case that


we want to fill this table with air. The programmer challenged
me, so I'll enter strange numbers into the table.
2. At Login Form
• Since John Wick is my idol, I'll help him out by making the
number of water he used negative. So he won't need to worry
about paying water bills

• Why can't I add? I can't I help John Wick not have to worry
about his monthly bills.
• Well, I had to enter the true amount of water he used.
2. At Login Form
• And this time it was successful. But, I entered the wrong
value, I need to correct it before someone sees it.
2. At Login Form
• Okay, now I will adjust the value at this month to the correct
number which is 58.
3. Customer details
• Luckily, I fixed it before anyone found out. Now I will check the details for him
and print the invoice. I just need to doubleclicked on his row.
3. Customer details
• Everything is fine, now I will print the invoice for him.
• Things are going wrong. My mom broke my printer because she
thought it was my router when she saw me playing games for 5
minutes after studying for 10 hours.
• Well, since the printer is gone, I will print at another time.
• I will remove his name from the list because I asked the masked guy I
just met on the street to print it for me.
4. Delete customer data
• I will remove his name from the list because I asked the masked
guy I just met on the street to print it for me.
• Done, my work for today is over. There's so much on my plate
today, I'll have to take a break
IX. IDE's function in enhancing algorithms
1.
Refactoring
• Improve code organization (rename variables,
extract methods, add comments). IDE can help us
refactor and update them throughout the entire
project and saves more time than when you
program with Notepad (Although I don't know
anyone who tries hard to program with
Notepad).
Before refactoring
3.

Code with IDE

V
e
r
4.
s
i
o
n
C
o
5.
n
t
r
o
l
(
6.
V
C
S
)
Unit Testing
• Write small tests to ensure code correctness.
7.

U
n
i
t
8.
T
e
s
t
i
n
g

u
s
i
n
g

N
U
n
i
t

i
n
9.
I
D
E

Profiling (for
efficiency)
• Identify performance bottlenecks to
optimize algorithms.
• It can
be
10.
relied on to check code that consumes a lot
of resources to fix,

Simple code that fill memory and use much CPU


Usi
ng
Pe
rfo
rm
an
ce
Pr
ofil
er,
yo
u
ca
n
fin
d
th
e
so
urc
e
11.
of
exc
ess
ive
res
ou
rce
us
ag
e
an
d
fro
m
th
ere
yo
u
ca
n
op
ti
mi
ze
th
at
co
de.
X. Enhance the algorithm written, using the features of the IDE
to manage the development process
1. Relationship between the algorithm and program code

Keep: Change:
• Problem-solving steps and overall logic remain • Syntax, data structures, and efficiency tweaks the same regardless
of the code's syntax (C#, adapt to the chosen language's features.
Python, etc.).

Example in Java Example in C#


Example algorithm

2. Possible challenges would face when converting the designed


algorithm into program code • Edge Cases and Error Handling: The
algorithm might not account for all
possible inputs (edge cases). You'll need to
Data Types and Structures:
add code to handle unexpected data or
• Limited Data Types: The chosen language might
errors gracefully.
not have a perfect data type to represent the
algorithm's data. You might need to use • I/O Handling: Algorithms typically focus on
workarounds or composite data structures (e.g., logic, but programs need to interact with
using a struct to combine multiple primitive types). the user or external systems. You'll need to
add code for input, output, and file
• Memory Management: Different languages handle
memory management differently. You might need handling based on the language's
to explicitly allocate and deallocate memory functionalities.
depending on the language (C++) or rely on • Readability and Maintainability: Even if the
garbage collection (Java).
code functions correctly, it might be
Control Structures: difficult to understand or modify. Using
clear variable names, comments, and
proper code structure is crucial for long-term maintainability.

XI. Coding Standard

Naming,Indent,Formatting

You might also like