Docsity

Object-Oriented Programming (OOP) and Design Patterns: A Comprehensive Guide, Assignments of Advanced Algorithms

Partial preview of the text

Download Object-Oriented Programming (OOP) and Design Patterns: A Comprehensive Guide and more Assignments Advanced Algorithms in PDF only on Docsity!

Higher Nationals in Computing

Advanced Programming - 1651

ASSIGNMENT

No.

Learner’s Name: Huỳnh Trần Anh Khoa

Assessor Name: NGUYEN NAM LAM

Class: 0903A

ID: GCS

Assignment due:

Assignment submitted:

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 20: Advanced Programming

Submission date August 29th 2022 Date Received 1st submission August 29th 2022

Re-submission Date Date Received 2nd submission

Student Name Huỳnh Trần Anh Khoa Student ID GCS

Class GCS0903A Assessor name Lâm Nguyễn Trung Nam

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

Grading grid

P1 P2 M1 M2 D1 D

X X

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date:

Lecturer Signature:

ASSIGNMENT 1 BRIEF

Qualification BTEC Level 5 HND Diploma in Computing

Unit number Unit 20 : Advanced Programming

Assignment title Examine and design solutions with OOP and Design Patterns

Academic Year 2018 - 2019

Unit Tutor Lâm Nguyễn Trung Nam

Issue date 25 April 2019 Submission date 7 May 2019

Submission Format:

Format: The submission is in the form of a group written report. This should be written in a concise,

formal business style using single spacing and font size 12. You are required to make use of

headings, paragraphs and subsections as appropriate, and all work must be supported with

research and referenced using the Harvard referencing system. Please also provide a

bibliography using the Harvard referencing system.

Submission Students are compulsory to submit the assignment in due date and in a way requested by the

Tutors. The form of submission will be a soft copy in PDF posted on corresponding course of

http://cms.greenwich.edu.vn/

Note: The Assignment must be your own work, and not copied by or from another student or from

books etc. If you use ideas, quotes or data (such as diagrams) from books, journals or other sources, you

must reference your sources, using the Harvard style. Make sure that you know how to reference properly,

and that understand the guidelines on plagiarism. If you do not, you definitely get fail

Assignment Brief and Guidance:

Scenario : You have recently joined a software development company to help improve their documentation of their in-houses software libraries which were developed with very poor documentation. As a result, it has been very difficult for the company to utilise their code in multiple projects due to poor documentation. Your role is to alleviate this situation by showing the efficient of UML diagrams in OOAD and Design Patterns in usages. Tasks You and your team need to explain characteristics of Object-oriented programming paradigm by applying Object-oriented analysis and design on a given (assumed) scenario. The scenario can be small

Table of Contents

  • P1 Examine the characteristics of the object-orientated paradigm as well as the various class relationships.
      1. What is Object Oriented Programming
      1. Top Characteristics of Object Oriented Programming:
      • Object-Oriented Development (OOD):
      • Encapsulation:
      • Abstraction:
      • Classes and Objects:
      • Inheritance and Composition:
      • Binding:
      • Message Passing:
      1. Object- Orientated Class relationships
      • Generalization/ Inheritance
      • Realization
      • Dependency
      1. Design Pattern
      • Definition
      • Why we should use design pattern.
      • Type of design pattern.
  • P2 Design and build class diagrams using a UML tool.
      1. Introduction about scenario
      1. Use-case diagrams:-
    • 3.Class Diagram
    • 4 .Pseudo code
      1. Activity diagrams:
      • Login:
      • Create account:
      • Add new book:
      • Remove book:
      • Borrow book:
  • References

Figure 01: Example of OOP

Above is an illustration of an employee record where each person may be seen as a "object."

Every employee has a name, age, and job title, therefore they may all be referred to as their

"properties."

2) Top Characteristics of Object Oriented Programming:

In order to get started, let's examine the features of object-oriented programming (OOP):

Object-Oriented Development (OOD):

The focus on objects in object-oriented programming is its primary feature. When an object

is defined by a developer, OOP is at its most fundamental. These objects may be used to

create and communicate data, set business rules, and even manage the behavior of the

programming environment. These objects are made by programmers using the OOD method.

They develop a blueprint that specifies how these things will function in relation to one

another. The interface is the name of this design. The methods that an object will be able to

use in its interactions with other objects are specified in the blueprint. Functions are a

common name for these methods. Properties, or the characteristics of the object that can be

accessible by other objects, are additional elements of the object that may be defined via the

interface. Interaction between objects has a dynamic interface. The programmers can alter it

to take into consideration brand-new interactions between the items. The benefit of OOP is

that it enables programmers to modify and grow their creations as necessary.

Figure 02: Object-Oriented Development

Encapsulation:

Another feature of OOP is the emphasis on data and functionality encapsulation within

objects. Objects are defined with particular functionality that determines how the objects

interact with one another. Data encapsulation is a critical component of OOP. This is due to

the fact that it prohibits hackers from changing data saved in the database. If hackers are able

to change the data in the database, the consequences for the firm might be severe. The

method through which programmers segregate data within an object is known as

encapsulation. It stops hackers from examining the data's specifics as well as the database's

structure. The two primary components of the OOP paradigm that promote security are data

encapsulation and abstraction. ata. Any programming framework meant to hold sensitive

data must have these.

Figure 04: Code of encapsulation 02

Figure 05 : Encapsulation

Abstraction:

The feature of abstraction comes next. This is the process of developing reusable objects to

standardize common business logic. The way things are utilized is a key aspect of

abstraction. They should be utilized consistently throughout a wide range of applications.

This standardizes the logic and makes it easy to maintain across different apps. Aside from

helping to standardize and maintain the logic, abstraction makes it easy for others to utilize

OOP in their projects. It promotes teamwork among several parties, making it simpler to

develop software that combines various data sources and functions. Programs that are far

more scalable and maintained than conventional non-OOP applications can be made.

However, in order to achieve this, abstraction is necessary.

Figure 06: Code of Abstraction

Figure 08: Code of Class and Objects

Figure 09 : Classes and Objects

Inheritance and Composition:

Inheritance and composition are another feature of OOP. The technique of allowing one

object to generate another is known as inheritance. It effectively lets one object to "inherit"

another object's attributes, methods, and other characteristics. The practice of mixing many

items to produce a new and distinct entity is known as composition. It effectively allows

programmers to reuse parts peculiar to other objects in order to generate a new and distinct

entity. One of the most essential characteristics of OOP is the ability to combine objects and

inherit their attributes. In every programming language, this is how objects are generated and

utilized. It is the basis of OOP.

Figure 11 : Inheritance vs Composition

Binding:

Binding is the process of connecting one object's property to another object in your program.

You may, for example, tie a text box to a button's text property so that when the button is

chosen, the text box's value is set to whatever was written into the text box. Binding a form

to a button in a web application will make it much easier to handle and debug your code as it

runs on the server. Dynamic binding and static binding are the two forms of binding. When

the value of one object changes and as a result, the value of another object's property also

changes, this is known as dynamic binding. When one of an object's properties is set directly

without affecting another property, this is known as static binding. Because static binding

allows developers control over precisely what values get set in each property, it is very

simple for developers to determine where their code is executing in the application. Dynamic

binding, on the other hand, might be trickier because it lets you modify properties in

response to user input or other app-related events. Dynamic binding also has a higher error

rate since updating one property might trigger unanticipated changes in other values and

could cause your program to crash if something goes wrong during execution.

Figure 12 : Binding

Message Passing:

The ability to transfer data around a program is critical in object-oriented programming. The

essential principle underlying data passing is that each item keeps track of its own state while

also knowing how to pass it along to other things. When an object wishes to transfer data to

another object, it simply calls the corresponding method on that other object. This allows

items to talk with one another and form intricate chains of objects. Message forwarding is