I. Programming Paradigms

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

I.

PROGRAMMING PARADIGMS
A. Introduce several programming paradigms
1. Procedural programming
a) Definition
Procedure programming is the first programming model that programmers will learn. Procedure
programming divides a program into smaller procedures, or functions, that contain the steps to be performed.
To make it more understandable, the procedural programming will write down lists of instructions for the
computer to do step by step what needs to be done in the most reasonable way to complete the task.

(Bhatia, 2020)

b) Features
❖ Predefined functions: Predefined functions are methods that have been defined or otherwise built
into the library of the program you use.
❖ Local Variable: The declaration is in the main structure of the method and it is limited to the local
scope it is given. Local variables can only be used in the method defined.
❖ Global Variable: External declaration of all other functions defined in the code. Therefore, global
variables can be used in all functions, unlike a local variable.
❖ Modularity: Grouping two systems are available with two different tasks to complete a larger task.
Each system group will then complete each task until all the tasks are completed.
❖ Parameter Passing: A mechanism used to pass parameters to functions, subroutines or procedures.

(Bhatia, 2020)

c) Advantages and Disadvantages


Advantages Disadvantages
• Contains a large amount of online • When the procedure programming is used,
references on experimental algorithms, the program code will be more difficult to
making learning easier. write.
• Don’t need to copy the code because you • Difficult to relate with real world objects.
can reuse it in different parts of the • The Procedural code is often not reusable.
program. • No data security is allowed because the
• Easily track program flow. data is exposed to the entire program.
• Needs only less memory. (Bhatia, 2020)
• Its relative simplicity, and ease of
implementation of compilers and
interpreters. (Bhatia, 2020)

1
2. OOP
a) Definition
Object-Oriented Programming (OOP) refers to a type of computer programming (software design) in
which programmers define the data type of a data structure, and also the types of operations (functions)
that can be applied to the data structure.

This makes the data structure becomes an object that includes both data and functions. In addition,
programmers can create relationships between one object and another. For example, objects can inherit
characteristics from other objects. (Beal, n.d.)

b) Principles
❖ Abstraction: The process of picking out (abstracting) common features of objects and procedures.
❖ Class: A category of objects. The class defines all the common properties of the different objects
that belong to it.
❖ Encapsulation: The process of combining elements to create a new entity. A procedure is a type of
encapsulation because it combines a series of computer instructions.
❖ Information hiding: The process of hiding details of an object or function. Information hiding is a
powerful programming technique because it reduces complexity.
❖ Inheritance: a feature that represents the "is a" relationship between different classes.
❖ Interface: the languages and codes that the applications use to communicate with each other and
with the hardware.
❖ Messaging: Message passing is a form of communication used in parallel programming and object-
oriented programming.
❖ Object: a self-contained entity that consists of both data and procedures to manipulate the data.
❖ Polymorphism: A programming language's ability to process objects differently depending on their
data type or class.
❖ Procedure: a section of a program that performs a specific task.

(Beal, n.d.)

2
c) Advantages and Disadvantages
Advantages Disadvantages
• Contribute to greater programming • Complex design
productivity. • Large size & Many instructions
• Better software quality. • Requires the mastery in software
• Less maintenance costs. engineering and programming
• Making the use of inheritance, redundant methodology.
code is eliminated, and the existing class is • Slow speed
extended. • Benefits only in long run while managing
• Easy management. large software projects.
• System can be easily upgraded from small (Magar, 2018)
to large systems.
• Code reusability is much easier than
conventional programming languages.
• Through data hiding, programmer can
build secure programs that cannot be
invaded by code in other parts of the
program.
• Real world entities.
(Magar, 2018)

3. Event-driven programming
a) Definition
Event-driven programming is currently the default paradigm in software engineering. As the name suggests,
it uses events as the basis for developing the software. These events can be something the users are doing -
clicking on a specific button, picking an option from drop-down, typing text into a field, giving voice
commands, or uploading a video - or system-generated events such as a program loading. (Helendi, 2018)

b) Features
❖ Service Oriented: This is a key features in event-driven programming that used to write programs
that are made for services and it takes does not slow down the computer.
❖ Time Driven: This is a paradigm, it’s a code that runs on a time trigger, time driven can be a specific
code that runs on a specific time, which could be once an hour, once a week or once a month, this
means it’s a pre-set to do task.
❖ Event Handlers: This is a type of function or method that run a specific action when a specific
event is triggered.
❖ Trigger Functions: These are functions that determine which code will run when a specific event
occurs, which are used to select which event handler to use for the event when there is specific event
occurred.
❖ Events: Events include mouse, keyboard and user interface, which events need to be triggered in
the program in order to happen, that mean user have to interacts with an object in the program.

3
(Anon., 2017)

c) Advantages and Disadvantages


Advantages Disadvantages
• On the business development side, • Since it offers the most value for GUI
keeping the user engaged with your applications, some other use cases might
program is one clear way of making sure not benefit from it.
your app is actively used and offers value. • Hard to master and not worth the hassle
• Serve users with the fastest and most when the app is so simple and small.
accurate feedback and this often • The flow of the program is usually less
translates into better user experience and logical and obvious.
business benefits. (Helendi, 2018)
• The software does not need any user input
to act.
• It is very intuitive and flexible.
(Helendi, 2018)

4. Compare
Procedural programming OOP Event-driven programming
• Program is divided into • Program is divided into • The flow of the program
small parts called small parts called objects. is determined by events
functions. • Follow the bottom-up such as user actions
• Follow the top-down approach. (mouse clicks, key
approach. • There are access presses).
• There is no access specifiers such as private, • The software does not
specifier. public, protected, etc. need any user input to
• Adding new data and • Adding new data and act.
function is not easy. function is easy. • It is very intuitive and
• There is not have any • Provide data hiding so it flexible.
proper way for hiding is more secure. • Hard to master and not
data so it is less secure. • Overloading is possible. worth the hassle when
• Overloading is not • Function is more the app is so simple and
possible. important than data. small.
• Function is more • Based on the real world. • Based on the real world.
important than data. • C++, Java, Python, C# • It can be practiced with
• Based on the unreal etc. any programming
world. (pankaj, n.d.) language.
• C, FORTRAN, Pascal, (pankaj, n.d.)
Basic etc.
(pankaj, n.d.)

4
II. PROGRAM RESULTS
A. Scenario – Problem – Solution
1. Scenario
Bi Baber usually pays customers manually, which causes inconvenience when customers use many services
at the same time and currently Bi Barber wants to be more convenient in paying their services. In addition,
Bi Barber also wants to be able to know the date of service and basic information such as the name and
phone number of customers to help customers who want to repair their hair if not satisfied in 3 days after
using service at Bi Barber.

2. Problem
The desire to make Bi Barber's services more convenient in paying them had to take time to update the
services and their prices. This also makes Bi Barber need to find a convenient solution but also needs high
accuracy in calculating the total price of services that customers use.

3. Solution
Applying the knowledge learned and to handle the difficulties that Bi Barber is facing, I have created an
electronic bill software to make Bi Barber more convenient in paying their services. In this software, I have
additional functions that Bi Barber needs such as service date and basic information of customers.

5
B. Explanation of Codes

6
F

7
1. Services
a) Source Code

8
b) Explanation
❖ Declare “int money1, money2, money3, money4, money5, money6;”
❖ Services:
• Haircuts: Use “if-else” with the condition "(chkHaircuts.CheckState = =
CheckState.Checked)" then for "money1 = 70000;" when users choose this service and give
"money1 = 0;" when the user does not choose.
• Tattoo Hair: Use “if-else” with the condition "(chkTattooHair.CheckState = =
CheckState.Checked)" then for "money2 = 60000;" when users choose this service and give
"money2 = 0;" when the user does not choose.
• Hair Dye: Use “if-else” with the condition "(chkHairDye.CheckState = =
CheckState.Checked)" then for "money3 = 300000;" when users choose this service and give
"money3 = 0;" when the user does not choose.
• Hair Remover: Use “if-else” with the condition "(chkHairRemover.CheckState = =
CheckState.Checked)" then for "money4 = 80000;" when users choose this service and give
"money4 = 0;" when the user does not choose.
• Hair Perm: Use “if-else” with the condition "(chkHairPerm.CheckState = =
CheckState.Checked)" then for "money5 = 200000;" when users choose this service and give
"money5 = 0;" when the user does not choose.
• Shampoo: Use “if-else” with the condition "(chkShampoo.CheckState = =
CheckState.Checked)" then for "money6 = 30000;" when users choose this service and give
"money6 = 0;" when the user does not choose.

2. Pay
a) Source Code

b) Explanation
❖ The program uses formula to calculate the total: “money1 + money2 + money3 + money4 + money5
+ money6 ” to calculate the total payment and display it in the “Total” text box.
❖ Create a “Message box” to display customer information and the total amount of money customers
need to pay.

9
3. Exit
a) Source Code

b) Explanation
❖ The program uses DialogResult to create a “Message box” to alert users with the question "Do
you want to exit?" with "OK" and "Cancel" options.
❖ Use “if ” with the condition “(warning = = DialogResult.OK)” to exit the program when the user
selects "OK".

10
III. IDE USAGE IN DEVELOPMENT
A. Common IDE features
1. Text editor
Virtually every IDE will have a text editor designed to write and manipulate source code. Some tools may
have visual components to drag and drop front-end components, but most have a simple interface with
language-specific syntax highlighting. (Walker, 2018)

2. Debugger
Debugging tools assist users in identifying and remedying errors within source code. They often simulate
real-world scenarios to test functionality and performance. Programmers and software engineers can usually
test the various segments of code and identify errors before the application is released. (Walker, 2018)

3. Compiler
Compilers are components that translate programming language into a form machines can process, such as
binary code. The machine code is analyzed to ensure its accuracy. The compiler then parses and optimizes
the code to optimize performance. (Walker, 2018)

4. Code completion
Code complete features assist programmers by intelligently identifying and inserting common code
components. These features save developers time writing code and reduce the likelihood of typos and bugs.

(Walker, 2018)

5. Programming language support


IDEs are typically specific to a single programming language, though several also offer multi-language
support. As such, the first step is to figure out which languages you will be coding in and narrow your
prospective IDE list down accordingly. (Walker, 2018)

6. Integrations and plugins


With the name integrated development environment, it is no surprise that integrations need to be considered
when looking at IDEs. Your IDE is your development portal, so being able to incorporate all your other
development tools will improve development workflows and productivity. (Walker, 2018)

11
IV. REFERENCES
Anon., 2017. ukessays. [Online]
Available at: https://www.ukessays.com/essays/computer-science/eventdriven-programming-features-
6167.php
[Accessed 30 04 2020].

Anon., n.d. The Economic Times. [Online]


Available at: https://economictimes.indiatimes.com/definition/debugging
[Accessed 02 05 2020].

Beal, V., n.d. webopedia. [Online]


Available at: https://www.webopedia.com/TERM/O/objectorientedprogrammingOOP.html
[Accessed 30 04 2020].

Bhatia, S., 2020. hackr. [Online]


Available at: https://hackr.io/blog/procedural-programming
[Accessed 30 04 2020].

Helendi, A., 2018. dzone. [Online]


Available at: https://dzone.com/articles/what-is-event-driven-programming-and-why-is-it-so
[Accessed 30 04 2020].

Magar, A. T., 2018. thecompletecodes. [Online]


Available at: https://www.thecompletecodes.com/2018/05/advantages-and-disadvantages-of-oop.html
[Accessed 30 04 2020].

pankaj, n.d. GeeksforGeeks. [Online]


Available at: https://www.geeksforgeeks.org/differences-between-procedural-and-object-oriented-
programming/
[Accessed 30 04 2020].

Walker, A., 2018. Learning Hub. [Online]


Available at: https://learn.g2.com/ide#ide-features
[Accessed 02 05 2020].

12
13

You might also like