TungDT BH02089 AssignmentII Programming st2
TungDT BH02089 AssignmentII Programming st2
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 HIEU
Grading grid
P3 P4 P5 P6 M2 M3 M4 D2 D3 D4
1
Grading grid
P3 P4 P5 P6 M2 M3 M4 D2 D3 D4
2
❒ Summative Feedback: ❒ Resubmission Feedback:
Lecturer Signature:
1
Table of Contents
3. Determine the debugging process and explain the importance of a coding standard. (LO4)....................42
3.1. Explain the debugging process and explain the debugging facilities available in the IDE. (P5)..............................42
3.2. Explain the coding standard you have used in your code. (P6).............................................................................47
4. CONCLUSION................................................................................................................................56
5. CRITICAL EVALUATE......................................................................................................................57
6. REFERENTCE.................................................................................................................................58
2
figure 5: Source code of POP.......................................................................................................................................9
figure 6: Code run example.........................................................................................................................................9
figure 7: Object oriented programming(OOP).............................................................................................................9
figure 8: Characteristic of OOP..................................................................................................................................10
figure 9: class.............................................................................................................................................................11
figure 10: Objects......................................................................................................................................................11
figure 11: Data abtraction.........................................................................................................................................12
figure 12: Data encapsulation....................................................................................................................................12
figure 13: Polymorphism in OOP...............................................................................................................................13
figure 14: Inheritance................................................................................................................................................14
figure 15: OOP example code...................................................................................................................................16
figure 16: Code run....................................................................................................................................................17
figure 17: Event-driven programming.......................................................................................................................17
figure 18: Source code of login interface and creat an accout..................................................................................21
I. INTRODUCTION.
3
figure 1: Programming
In response to the increasing demand for efficient and secure software solutions, our
research and development team has embarked on a mission to explore the most effective
programming paradigms for developing a water bill calculation application. This report
serves as a comprehensive overview of three key programming paradigms – procedural,
object-oriented, and event-driven programming – as we seek to identify the most
suitable approach for our project.
As we delve into the characteristics, advantages, and disadvantages of each paradigm, our
goal is to lay the groundwork for making informed decisions in the development process.
Beyond theoretical considerations, our team has been entrusted with the challenging task of
creating a fully functional, secure application. This application will be developed using an
Integrated Development Environment (IDE) and will strictly adhere to coding standards,
ensuring both efficiency and adherence to industry best practices.
This introduction sets the stage for our exploration of programming paradigms and
introduces the subsequent analysis of their applicability to our water bill calculation
application. The report not only aims to provide a theoretical understanding but also
outlines the practical challenges that our team will navigate in the pursuit of a robust and
user- friendly software solution.
II. CONTENTS.
1. Explain the characteristics of procedural, object-oriented and event-driven
programming. (LO2)
First, I want to present about programming models to clearly understand why there are
different programming models in the world and how to apply it in practice:
4
figure 2: Programming paradigm
6
Next, I would like to go deeper into each paradigms.
7
figure 4: characteristics of POP
8
• Most of the functions share global data.
An example of POP:
Source code:
9
figure 5: Source code of POP
Code run:
Definition OOPs:
10
Object-Oriented Programming (OOP) is a programming paradigm in computer
science that relies on the concept of classes and objects. It is used to structure a
software program into simple, reusable pieces of code blueprints (usually called
classes), which are used to create individual instances of objects. There are
many object-oriented programming languages, including JavaScript, C++, Java,
and Python.
In OOP, There are six characteristics popular in all the language of computer (Tran, 2021):
Class: Classes are the blueprints or templates that define the attributes and
methods of objects. Classes can be used to create instances of objects that
share the same properties and behavior. For example, a class named Car
can define the attributes such as color, brand, and model, and the methods
such as start, stop, and accelerate. A class can also have constructors,
which are special methods that are used to initialize the objects when they
are created.
11
figure 9: class
Objects: Objects are the basic units of software that represent real-world entities.
Objects have an identity, state, and behavior. Each object contains data and code
to manipulate the data. Objects can interact with each other by sending messages
or calling methods.
12
figure 11: Data abtraction
Data Encapsulation:
The bundling data (attributes) and methods that operate on the data
within a single unit (class). It helps control access to the data and ensures
data security.
13
subclass to modify or extend the behavior of the superclass. Method
overloading is when a class defines multiple methods with the same name
but different parameters. This allows the class to provide different ways of
performing the same task. For example, a class named Calculator can have
multiple methods named add that can take different types or numbers of
arguments.
14
figure 14: Inheritance
Advantages of OOPs:
Disadvantages of OOPs:
15
The programming guide object is a method implementation that uses objects as
the unit basis of the software. Objects have specifically defined data (properties)
and behavior (methods) and their functions. Objects can interact with each other
by sending messages or calling methods. Objective programming guides making
source code modular, using regeneration and adaptation using concepts such as
classes, inheritance, polymorphism, and encapsulation.
Application of OOPs:
- AI Expert Systems
- CIM/CAD/CAM Systems
An example of OOPs:
16
- This example will simulate a simple object class "Person" with properties such as
name, age, and method to display the person's information:
Source code:
Code Run:
17
figure 16: Code run
Definition EDP:
18
Event-driven programming also allows us to scale large systems easily by increasing the
number of consumers.
- Event Loops: Fundamental part that continuously monitors and dispatches events to
event handlers.
- User-Driven Interaction: User interactions drive program execution, waiting for user
actions before proceeding.
Advantages of EDP:
19
- Convenience: Predictive coding is another feature of event driven programming.
With the help of languages like visual basic, predictive coding is made possible. When
the developer is typing the code, the relevant suggestions are given.
- Flexibility: In event driven programming, there is no specific order from start to finish.
This order can make it easy to carry out the code. In addition to that, this is a type of code
that can be altered when necessary. If there is a requirement or errors in coding, the
code is flexible to be changed.
Disadvantages of EDP:
- Resource Utilization: Event driven programming uses main loop which is well known to
drain system resources. Because, the main loop is constantly functioning in the
background. Moreover, due to the usage of GUI, EDP cannot provide an interface unless
the required specifications are met.
- Language Translation: Once a program is written using the EDP language, you
cannot translate it to a different language. Because some functionalities like button are
programmed to work only with event driven programming.
20
example, the program visual basic works using windows library files. If the program is
moved to a different OS, these files cannot be found
An example of OOPs:
21
figure 18: Source code of login interface and creat an accout
22
POP (Procedural Oriented Programming), OOP (Object-Oriented Programming), and
EDP (Event-Driven Programming) are three different programming paradigms, and they
have the following relationships and differences:
Description: A programming model that focuses on the process (or order of steps) and
functions or methods.
Characteristic:
23
Figure 21: OOP
Description: A programming model that focuses on objects, each object has state (data) and behavior
(methods).
Characteristic:
Description: A programming model that focuses on event handling and reactions when
events occur.
Characteristic:
Programs are designed to respond to events such as mouse clicks, key presses, or system events.
Commonly used in applications with a user interface, where user interactions generate events.
24
Although it is possible to use both POP and OOP in a project, they often reflect different
implementations and design decisions.
EDP is often integrated with both POP and OOP. In an OOP environment, objects can react on
events, while POPs can be used to handle specific events.
An application can use both POP and OOP for the logic model, while using EDP for user event
handling.
In summary, POP, OOP, and EDP are not necessarily mutually exclusive and are often combined
to create powerful and efficient applications. The choice between them depends on the specific
requirements of the project and the satisfaction of the development team.
Procedural:
o Look for functions or procedures that carry out specific tasks in a step-by-step
manner.
o Check if the code follows a sequential flow.
Object-Oriented:
Event-Driven:
25
1.3. Critically evaluate the source code of an application that implements
the procedural, object-orientated and event-driven paradigms, in terms
of the code structure and characteristics. (D2)
2. Implement basic algorithms in code using an IDE. (LO3)
Introduction about IDE:
- IDE definition: IDE is the Integrated Development Environment that provides the
user interface for code development, testing, and debugging features. It helps to
organize the project artifacts relevant to the software application’s source code. It
provides several tools and features to make development easy and standardized
based on the programming language the developer writes the code. The IDEs also
have the functionalities to compile and interpret the program. Some widely used IDs
are Eclipse for Java programming development, Microsoft Visual Studio, Android
Studio for Mobile Apps Development, RStudio for R programs, and PyCharm for
Python programming.
26
- Visual Studio is a well-known and widely used integrated development
environment (IDE) among professional programmers, particularly those working
with languages like VB+ and C#. It has a rich history of development and continuous
improvement over the years.
- History of Visual Studio: Visual Studio was first released in 1997. The first version of
Visual Studio was numbered "Visual Studio 97" and was released in February
1997. Before that, Microsoft had separate development tools. for each language
such as Visual Basic, Visual C++ and Visual FoxPro.
27
- In this part, I will write an event-driven program that creates a Windows form to caculate
a water bill. First, I will talk about the properties and functions of the components that I
will use to write the program:
+ I will write a program Winforms that uses the IDE that is Visual Studio to create a user
interface with common main functions such as login / account creation and user interface,
these functions including:
Login
Main:
28
Figure 26: main form
29
Design the customer management form interface as follows:
30
Figure 29: login button
31
Figure 30: add button
32
Figure 31: update button
33
Figure 32: search button
34
Figure 33: calculate-function
35
Figure 34: delete function
To expand the program, we build a login form so users can log in before entering the
36
Figure 35: login form
Program result
If the user enters the wrong username or password, the program will display the message ; User
or the password is incorrect! .
In case the user enters the correct username and password, button. And then the invoice
management interface will appear:
37
Figure 36: display screen
In case the user enters the correct username and password, button. And then the invoice
management interface will appear:
38
Figure 37: form login correct
39
If you press the 'back' button, you will return to the invoice page
40
Figure 40: edit successful
41
And here is the bill to calculate the money bill:
42
2.2. Enhance the algorithm written, using the features of the IDE
to manage the development process. (M3)
3. Determine the debugging process and explain the importance of a
43
• Debug process: The debugging process is a crucial part of software
development that involves identifying and fixing errors, defects, or
unexpected behaviors in a program.
• What is debuging:
o Debugging is the process of identifying and fixing errors, defects, or
unexpected behaviors in a software program. The term "bug" was famously
coined by Grace Hopper when an actual moth caused a malfunction in the
Mark II computer in 1947. Debugging is an essential part of the software
development lifecycle and is performed to ensure that a program behaves as
intended and produces the correct results.
o The primary goals of debugging are:
o
o Identifying Issues:
o
o Understanding and recognizing that there is a problem in the code. This
could be due to logical errors, syntax mistakes, or unexpected behaviors.
o Isolating the Problem:
o Narrowing down the scope of the issue to specific sections of code or
modules. This helps in focusing efforts on the part of the code where the
problem is located.
o Analyzing the Cause:
o Investigating the root cause of the problem. This involves examining the
code, variables, and program flow to understand why the software is not
behaving as expected.
o Fixing the Bug:
o Implementing corrections or modifications to the code to eliminate the
identified issue. This could involve changing the logic, fixing syntax errors,
or adjusting the program's configuration.
o Verifying the Fix:
44
o Testing the modified code to ensure that the issue has been resolved and
that the program now functions correctly. This often involves running various
test cases to validate the software's behavior.
o Debugging techniques can vary and may include:
o Print Statements: Inserting statements in the code to print out variable
values or status messages at different points in the program's execution.
o Logging: Using logging frameworks to capture information about
the program's behavior during runtime.
o Debugging Tools: Leveraging integrated development environments (IDEs)
and specific debugging tools to set breakpoints, step through code, and
inspect variables.
o Code Reviews: Collaborating with team members to review the code
and identify potential issues.
o Unit Testing: Writing and running automated tests to verify the correctness
of individual units or components of the code.
o Profiling: Analyzing the program's performance and resource usage to
identify bottlenecks or inefficiencies.
Why it is important?
o Identifying and Fixing Errors: Debugging is the process through which programmers
identify and correct errors, bugs, or unexpected behaviors in their code. This is
essential for ensuring that a software program works as intended and produces
the correct results.
o Ensuring Software Reliability: Debugging contributes to the overall reliability and
stability of software. By identifying and fixing issues, developers can prevent software
from crashing, hanging, or producing incorrect outputs, which improves the user
experience.
o Maintaining Code Quality: Debugging is a fundamental aspect of maintaining
code quality.
o Identifying and resolving issues leads to cleaner, more readable, and more
maintainable code.
45
o This is crucial for the long-term sustainability of a software project.
o Meeting User Expectations: Debugging helps ensure that the software meets user
expectations and requirements. Users expect software to behave as specified, and
debugging is the process that bridges the gap between the intended functionality
and the actual behavior.
o Saving Time and Resources: Early and effective debugging can save significant time
and resources in the software development lifecycle. Identifying and fixing issues
during development or testing phases is generally more efficient than dealing with
problems after the software has been deployed.
o Enhancing Developer Productivity: Debugging tools and techniques, such as
integrated development environments (IDEs) and version control systems, contribute
to developer productivity. These tools streamline the process of locating and fixing
bugs, allowing developers to work more efficiently.
o Improving Software Security: Bugs or vulnerabilities in software can be exploited by
malicious actors. Debugging is an essential step in identifying and fixing security-
related issues, thus improving the overall security posture of the software.
o Facilitating Collaboration: In a collaborative development environment, debugging
helps team members understand and troubleshoot each other's code. Code reviews
and collaborative debugging sessions contribute to knowledge sharing and the
overall success of the team.
o Supporting Continuous Integration and Deployment: Debugging is crucial in
continuous integration and deployment workflows. It ensures that code changes are
thoroughly tested, and any issues are addressed before new versions of the software
are deployed. Enhancing the Development Process: The insights gained during the
debugging process contribute to a developer's understanding of the software. This
knowledge can be applied to improve future coding practices and avoid similar
issues in subsequent projects
The Debugger
A debugger is a software tool that helps programmers identify and fix errors, bugs, and
unexpected behaviors in their code. Debuggers provide a set of features and
capabilities that assist developers in analyzing the execution of a program, inspecting
variables, setting breakpoints, and controlling the flow of code during runtime. The
primary goal of a debugger is to make the debugging process more efficient and
effective.
Describe the debugging process:
46
Coding standards:
o Coding standards are a set of guidelines and rules that developers follow when
writing code. These standards are designed to ensure consistency, readability, and
maintainability of code across a software project or development team. Adopting
coding standards has several benefits, including improved collaboration, easier
debugging, and enhanced overall code quality. While specific coding standards
may vary based on the programming language and the preferences of a
development team or organization, some common elements include:
o Indentation and Formatting:
o Consistent indentation helps improve code readability. Standards often specify the
number of spaces or tabs for each level of indentation. Additionally, guidelines for
code formatting, such as line length limits and placement of braces, contribute to
a consistent code style.
o Naming Conventions:
o Guidelines for naming variables, functions, classes, and other code elements help
maintain clarity and consistency. Common conventions include using camelCase or
snake_case for variable names and following specific patterns for class names.
o Comments and Documentation:
o Standards often define how and when to use comments in the code. This includes
providing explanations for complex sections, commenting on the purpose of
functions or methods, and documenting code interfaces. Consistent documentation
improves code understanding for both current and future developers.
o Code Structure:
o Standards may provide guidance on how to structure code files, organize imports,
and arrange functions or methods within a file or class. A consistent structure
makes it easier for developers to navigate and understand the codebase.
o Error Handling:
o Guidelines for error handling and exception usage help ensure that code
responds appropriately to unexpected situations. Consistent error-handling
practices contribute to robust and reliable software.
o Variable Declarations:
o Standards often specify how to declare variables, including rules for variable
initialization, constant naming conventions, and the use of global or local variables.
Naming Conventions:
47
3.2. Explain the coding standard you have used in your code. (P6)
Analyze the common features of an IDE:
Code editor: A code editor is a text editor that allows developers to write and edit source
code. It usually supports syntax highlighting, code completion, code folding, and error
checking. It may also offer features such as code snippets, refactoring tools, and code
navigation.
Debugger: A debugger is a tool that helps developers to test and debug their code. It
allows developers to run their code step by step, inspect the values of variables, set
breakpoints, and watch expressions. It also shows the locations of errors and exceptions
in the code and provides information about the program state and stack trace.
Terminal: A terminal is a text-based interface that allows developers to interact with the
operating system and execute commands. It can be used to run scripts, compile code,
launch applications, and perform other tasks. Some IDEs have a built-in terminal that can
be accessed from within the IDE, while others require external terminals to be opened
separately.
Version control: Version control is a system that helps developers to track and manage
the changes to their code. It allows developers to create, merge, and switch between
48
different versions of their code, as well as collaborate with other developers. Some IDEs
support version control tools such as Git, SVN, or Mercurial, and provide graphical
interfaces for performing common operations such as committing, pushing, pulling, and
branching.
Extensions and plugins: Extensions and plugins are additional components that can be
installed to extend the functionality of the IDE. They can provide support for specific
languages, frameworks, libraries, or features that are not included in the core IDE. For
example, some extensions and plugins can enable code formatting, linting, testing,
debugging, or documentation generation.
Compilation or Interpretation:
Compiler:
In languages like C or C++, a compiler is used to generate machine code from the source
code. The compiler checks for syntax errors, optimizes the code, and produces an
executable file. The resulting file can be run directly by the operating system.
Interpreter:
In languages like Python or JavaScript, an interpreter is used to execute the code. The
interpreter reads the source code line by line and performs the actions specified in the
code. Some interpreted languages may also use a Just-In-Time (JIT) compiler to optimize
performance.
49
Linking (for Compiled Languages):
In compiled languages, especially those with multiple source files, a linking step may be
necessary. Linking combines the machine code generated from different source files and
resolves references between them. This results in a single executable file.
Execution:
Users or systems execute the generated executable code. For compiled languages, this
typically involves running the executable file directly. For interpreted languages, the
interpreter or runtime environment executes the code.
Optimizations (Optional):
50
o Acceptance Testing: Verifying that the system satisfies the acceptance criteria and is
ready for deployment.
o Techniques:
o Manual Testing: Testers manually execute test cases without using any automation tools.
o Automated Testing: Using tools and scripts to automate the execution of test cases.
o Regression Testing: Testing the software after changes to ensure that existing functionalities
still work.
o Performance Testing: Evaluating the system's performance under different conditions.
o Best Practices:
o Early Testing: Start testing as early as possible in the development lifecycle.
o Test in Isolation: Ensure that tests are independent and can be run in isolation.
o Continuous Integration: Integrate testing into the development process using
continuous integration tools.
o Boundary Testing: Test the software at the boundaries of its input space to uncover
potential issues.
o Tools:
o Unit Testing Frameworks: Examples include JUnit (Java), NUnit (C#), and pytest (Python).
o Automation Tools: Selenium for web applications, JIRA for test management, etc.
o Performance Testing Tools: JMeter, Gatling, etc.
o Static Analysis Tools: SonarQube, ESLint, etc.
51
languages. Here are some popular programming languages and examples of IDEs that
support them:
• Java:
Eclipse
IntelliJ IDEA
NetBeans
• C/C++:
Visual Studio (Microsoft)
• Python:
PyCharm (by
JetBrains)
Spyder
• JavaScript:
Visual Studio
Code
Atom
• C#:
Visual Studio (Microsoft)
• PHP:
52
PhpStorm (by JetBrains)
53
Eclipse PDT
• Ruby:
RubyMine (by JetBrains)
IntelliJ IDEA
Visual Studio
Code Sublime
Text Atom
Language-Specific IDEs:
54
• Visual Studio Code: A lightweight, cross-platform IDE supporting various
languages.
• IntelliJ IDEA: Supports Java, Kotlin, Scala, and other languages.
• IDEs specifically designed for web development, including support for HTML,
CSS, JavaScript, and server-side languages.
• Visual Studio Code
• Atom
• Sublime Text
Mobile Development IDEs:
• IDEs tailored for mobile app development, often supporting languages like Java,
Kotlin, Swift, or languages specific to mobile platforms.
• Android Studio: For Android app development (supports Java and Kotlin).
• Xcode: For iOS app development (supports Swift and Objective-C).
• IDEs specialized for game development with tools and features specific to creating
games.
• Unity: For developing 2D and 3D games.
• Unreal Engine: For high-end game development.
5.8 Multi-language IDE
Multi-language IDEs (Integrated Development Environments) are tools that support and
provide features for multiple programming languages. These IDEs are versatile and
enable developers to work on projects involving different languages without having to
switch between different development environments.
55
Here are some popular multi-language IDEs:
Eclipse:
• Languages Supported: Java, C/C++, PHP, Python, Ruby, JavaScript, and more.
• Features: Highly extensible, supports a wide range of plugins for different
languages and frameworks.
NetBeans:
Sublime Text:
• Languages Supported: Python, JavaScript, HTML, CSS, Java, C++, and more.
56
• Features: Lightweight, fast, and supports many languages with a wide range
of plugins.
Code::Blocks:
Xcode:
• Languages Supported: Python, PHP, Ruby, JavaScript, HTML, CSS, and more.
• Features: Multi-language support, including strong capabilities for
web development..
4. CONCLUSION.
In tackling the formidable challenge of crafting a robust customer invoice management
application, I seamlessly employed a myriad of programming paradigms within the confines
of a sophisticated Integrated Development Environment (IDE). By embracing the tenets of
57
Object-Oriented Programming (OOP), I sculpted a codebase adorned with classes and
objects, thereby fostering an architecture that not only encapsulates functionality
but elevates reusability and maintainability to paramount heights.
Central to this triumph was the instrumental role played by a powerful IDE, an indispensable
companion in my development journey. The code editor, akin to a virtuoso conductor,
orchestrated lines of code with finesse; debugging tools acted as vigilant sentinels, guarding
against the incursion of bugs; version control integration facilitated a collaborative dance
with team members, ensuring a harmonious synchronization of efforts; and deployment
management unfurled a red carpet, easing the transition from the crucible of development
to the grand stage of production.
In the crucible of this interview task, I not only showcased my proficiency in programming
but also demonstrated a penchant for strategic thinking and problem-solving. The end
result is an impervious bastion of a customer invoice application, where OOP and event-
driven paradigms converge, and secure coding stands as a sentinel against the ever-looming
specter of data breaches. This experience has not only been a testament to my technical
prowess but also an ode to the collaborative symphony orchestrated by a potent IDE.
5. CRITICAL EVALUATE.
In undertaking the formidable task of creating a secure and fully functional customer invoice
management application, I harnessed various programming models within the realm of a
sophisticated Integrated Development Environment (IDE). The utilization of Object-Oriented
Programming (OOP) principles proved to be a cornerstone in structuring the codebase,
creating an architecture adorned with classes and objects. This approach not only enhanced
58
the organization of functionality but also fostered reusability and maintainability,
contributing to a robust foundation for the application.
The choice of a powerful IDE emerged as a strategic ally throughout the development
process. The code editor functioned as a precision instrument, facilitating the creation and
modification of code with efficiency. Debugging tools served as vigilant guardians,
identifying and rectifying potential issues, while version control integration and deployment
management streamlined collaboration and transition to the production environment.
However, as with any endeavor, critical evaluation unveils areas for potential improvement.
While OOP and Event-Driven Programming were implemented effectively, a deeper analysis
could reveal opportunities for optimization or alternative approaches. Additionally,
documentation and comments within the code could be scrutinized for clarity and
completeness, ensuring that future developers can navigate and comprehend the intricacies
of the application seamlessly.
In conclusion, this interview task not only demonstrated technical proficiency but also
underscored the importance of strategic thinking and problem-solving. The resulting
customer invoice application stands as a testament to the fusion of OOP and event-driven
paradigms, yet the critical eye remains vigilant for areas of refinement. The symbiotic
relationship with a robust IDE, while instrumental, prompts a continuous quest for
excellence and efficiency in the ever-evolving landscape of software development.
6. REFERENTCE.
59
Ooad - Object Oriented Paradigm (no date) Online Tutorials, Courses, and eBooks Library. Available
at:
https://www.tutorialspoint.com/object_oriented_analysis_design/ooad_object_oriented_paradig
m. htm
60