Download Comparative Analysis of Procedural-Oriented and Object-Oriented Programming and more Lecture notes Deductive Database Systems in PDF only on Docsity!
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 NGUYEN VAN TUNG Student ID BH Class SE06303 Assessor name NGUYEN THANH TRIEU 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 Tùng Grading grid P 3 P 4 P 5 P 6 M2 M3 M4 D2 D3 D
❒ Summative Feedback: ❒ Resubmission Feedback: Grade: Assessor Signature: Date:
Table of Contents
I. Introduction In today's advanced age many of the research and development teams you work with have been tasked with further research into the best way to build more efficient, secure software for calculating water bills. You have been asked to consider programming paradigms as well as the advantages and disadvantages of using different programming language approaches. You will need to create a report that includes findings from research on the characteristics of different programming paradigms - procedural, object-oriented, and event-oriented programming. You and your team are then given the more difficult task of creating a fully working, secure application developed using an IDE and complying with coding standards for a detailed business problem. **II. Content P3: Discuss what procedural, object-orientated and event-driven paradigms are; their characteristics and the relationship between them.
Procedure Oriented Programming (POP).**
Define Procedural language is a list of instructions telling a computer, step-by-step. In this programming practice developer write line by line code which executes a single action each line. In procedural programming first line of code is executed, then the second, then the third and so on, lines cannot jump from the 1st to the 7th to achieve something it must first complete 1-6 in order to get to the 7th line. procedural programming also focuses on the idea that all algorithms are executed with functions and data that the developer has access to and is able to change. Procedural programming uses a top down approach to executing codes. Examples of procedural languages are - BASIC, COBOL, PASCAL, FORTRAN, C and PL1.
Figure 1 : Procedure Oriented Programming
- Applicability Applications of procedural programming :
- Simple programs: POP is suitable for simple programs, with a clear structure and easy to understand. When a program requires only a sequential series of steps without much complexity in data or relationships between components, POP can be used effectively.
- Independent procedural tasks: When tasks in a program can be divided into independent procedures, POP helps separate them into separate blocks of processing. This aids in organization, code reuse, and easier management.
used to create GUI applications all have their own version of event-driven programming, such as C#, C++, Java, JavaScript, and Objective C. Figure 2 : Event-driven paradigms
- Applicability Event-driven programming (EDP) is applied in many situations:
- Graphical User Interface (GUI): EDP is commonly used in GUI development, where user interactions such as button clicks, mouse movements, or keyboard input trigger events that control behavior application. EDP allows for a responsive and interactive user interface.
- Interactive applications: EDP is suitable for developing interactive applications that require real-time responses to user actions or external events. This includes video games, simulations, virtual reality applications, and multimedia software.
- Asynchronous operations: EDP is useful for handling asynchronous operations, such as network communication, file I/O, or database queries. By using event-driven mechanisms, the program can continue performing other tasks while waiting for these operations to complete.
- IoT and Sensor-Based Systems: EDP is applicable in Internet of Things (IoT) and sensor-based systems, where events from external sensors or devices trigger actions or data processing. EDP enables real-time processing of data streams and response to environmental changes.
- Event-driven architecture: EDP is the foundation for event-driven architecture, in which different components or services communicate through events. This architectural style enables loose coupling, scalability, and flexibility in distributed systems.
- Reactive programming: EDP aligns with reactive programming principles, focusing on reacting to changes and propagating those changes through the system. Reactive programming is suitable for processing event or data streams and building responsive applications.
- Parallel and concurrent systems: EDP can be applied in concurrent and parallel systems, where different events can be processed simultaneously or in parallel. EDP enables efficient handling of multiple events and coordination of concurrent activities. It's important to note that while EDP offers benefits in event-driven scenarios, it may not be the best choice for every application. The choice of programming model depends on the specific requirements, performance constraints, and complexity of the system being developed.
- Characteristic Service orientated:
- Service oriented is a programming paradigm that is used to write programs that are made for services. If something is requested, the action is carried out, if a user wanted to minimize an application that they are using, they would click on the - icon in the top right of the page and the application will minimize into the task bar, this is service orientated. Time driven:
- Time driven in event driven programming is a paradigm, it is code that runs on a time trigger, this could be a piece of code that runs at a specific time, which could be once a week or whenever a program is launched, this means it is a pre-set task. An example of this is MAC OS X mavericks, it checks for updates at a specific time every day, if an update is found it informs you to do the update now or to postpone it to a later time or date.
Figure 3 : description about OOP
- Applicability Object-oriented programming (OOP) is applied:
- Complex systems: OOP is particularly suitable for developing complex systems with many interacting components. It enables modular design and encapsulation of data and behavior, making it easier to manage and maintain large-scale applications.
- Reusability: OOP promotes code reuse through the concept of inheritance and polymorphism. By creating reusable classes and leveraging inheritance, developers can reuse and extend existing code effectively, saving time and effort in software development.
- Modeling real-world entities: OOP is well suited to modeling real-world entities and their relationships. It allows developers to represent entities as objects with their properties (data) and behavior (methods), making the code more intuitive and closer to the problem domain.
- Graphical User Interface (GUI): OOP is commonly used in GUI development. GUI frameworks often use object-oriented principles to represent various visual elements, such as windows, buttons, and menus, as objects with their own properties and behavior.
- Collaboration and teamwork: OOP promotes collaboration and teamwork among developers. By encapsulating data and behavior in objects, different team members can work independently on different components without interfering with each other's code, as long as the interfaces remain consistent.
- Extensibility and maintainability: OOP provides flexible and extensible code structure. Adding new features or modifying existing features can be done by extending classes or overriding methods, rather than modifying the entire code base. This improves code maintainability and reduces the risk of errors.
- Software libraries and frameworks: Many software libraries and frameworks are built according to OOP principles. By understanding OOP concepts, developers can better use and integrate these libraries into their projects, taking advantage of their functionality and capabilities. It's important to note that while OOP offers many benefits, it may not be the best choice for every situation. The choice of programming model depends on the specific requirements, complexity and constraints of the project.
- Characteristic
- Class definitions - Basic building blocks OOP and a single entity which has data and operations on data together
- Objects - The instances of a class which are used in real functionality - its variables and operations
- Abstraction - Specifying what to do but not how to do; a flexible feature for having a overall view of an object's functionality.
- Encapsulation - Binding data and operations of data together in a single unit - A class adhere this feature
- Inheritance ard class hierarchy - Reusability and extension of existing classes
- Polymorphism - Multiple definitions for a single name - functions with same name with different functionality; saves time in investing many function names Operator and Function overloading.
- Class libraries — Built-in language specific classes
+POP: Neither it overload functions nor operators. +OOP: It overloads functions, constructors, and operators.
- Inherit: +POP: No inheritance support. +OOP: Inheritance is supported in three states "public", "private","protected".
- Confidentiality: +POP: There is no proper way to hide data, so data is not safe. +OOP: Data is hidden in three modes"public", "private", "protected" thus increasing data security.
- Data Sharing: +POP: System-wide data is shared between functions in the program. +OOP: Data is shared between objects through functions.
- Functions and Classes: +POP: There is no concept of functions and classes. +OOP: Classes or functions can become more communicative with each other with keywords. (depending on different languages, keywords will be different).
- Virtual classes or virtual function: +POP: There is no concept of virtual class. +OOP: The concept of virtual functionality appears in the process of succession.
- Commonly spoken languages: +POP: TC, VB, Pascal. +OOP: CH, JAVA, C # NET, Ruby,.... - The main difference between OOP and POP. The main focus of POP is on how the system does the task; it follows the flow chart to complete the task.
The main focus of OOP is data security because only objects of a class are allowed to access properties or functions of a class.
- The difference between Object Oriented Programming (OOP) and Event Driven Programming (EDP). Object Oriented Programming Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which are data structures that contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods Event Based/Driven Programming In computer programming, event-driven programming is a programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses), sensor outputs, or messages from other programs/threads Object oriented programming focuses on performing actions and manipulation of data that is encapsulated in objects within a sequential series of steps while event driven is more dynamic and relies on event triggering and event handling to determine thesequencing of the program. Event driven programs can have threads that perform actions based upon triggers/event in your program. With multi-threading it is possible to have numerous threads interacting with your code simultaneously. While multi-threading can take full advantage of the multiple cores in your CPU which can be faster, you have issues such as thread locking due to synchronization issues where multiple threads are trying to access the same object. Event driven programming will still have objects, but it will also have threads that are only initialized once an event has been triggered. Example: fire sprinkler system, let's say there is a sensor for detecting a fire and sprinkler system used to extinguish the fire. If we used only object oriented, we will create an endless loop that constantly checks the status of the sensor if it detects a fire we turn on the sprinkler, the program would work but it wouldn't be much use for any other task. In an event driven program, we could set an event that triggers a thread when the fire sensor activates, and we can create an event handler that would process the thread in order to tell the sprinkler system to turn on. In this fashion, our event program could also have other functionality as it is not stuck in an endless loop. P4: Write a program that implements an algorithm using an IDE. 1 .Write a program “Calculate monthly water bills for customers” to implement the algorithm using the IDE. ABC software has requested a simple program that will calculate the monthly water bill each month. The CEO of the company has reviewed the client requirements and has determined that this is a suitable project for you to take on. The company wants to see how you use and apply the development environments and code standards.
- Last month’s water meter readings
- This month’s water meter readings
- Amount of consumption (This month’s water meter readings - Last month’s water meter readings)
- Total water bill
- Sort, search for customer, generating invoices notifying customer and payments dues is one of the feature enhancement suggestions. The client has not specified any Graphical User Interface, but the CEO has left the design of the program completely up to you. 1 .1 Description of the problem The problem at hand is to create a simple software solution for calculating the total amount due for water bills based on user input. The software will not store customer information or the calculated bills, but rather display the total amount due after the data has been entered. 1 .2 Prepare the interface using win form then code and test.
- First step Create and design login form: Figure 4 : Create and design login form.
- Next step Form Dashboard Create a Forms Panel after the form login but in the same file:
Figure 5 : Form Dashboard Figure 6 : Form Dashboard