0% found this document useful (0 votes)
71 views13 pages

Unit 20 Assignment 1

The document provides details about an assignment for a BTEC Level 5 HND Diploma in Computing program. It includes information such as the qualification, unit number and title, submission date, student name and ID. It then describes the grading grid and provides sections for summative and resubmission feedback. The document serves as a cover page for the assignment which will include contents, OOP concepts, a scenario to demonstrate them, UML diagrams, and a discussion of design patterns.

Uploaded by

kcas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views13 pages

Unit 20 Assignment 1

The document provides details about an assignment for a BTEC Level 5 HND Diploma in Computing program. It includes information such as the qualification, unit number and title, submission date, student name and ID. It then describes the grading grid and provides sections for summative and resubmission feedback. The document serves as a cover page for the assignment which will include contents, OOP concepts, a scenario to demonstrate them, UML diagrams, and a discussion of design patterns.

Uploaded by

kcas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

ASSIGNMENT 1

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 20: Advanced Programming

Submission date 07 May 2022 Date Received 1st submission 07 May 2022

Re-submission Date Date Received 2nd submission

Student Name Pham Khac Thanh Phong Student ID GCH210005

Class GCH0905 Assessor name Doan Trung Tung

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 D2
 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date:


Lecturer Signature:
Table of Contents
1. Introduction ......................................................................................................................................................................................... 5
2. OOP general concepts ......................................................................................................................................................................... 5
3. OOP scenario........................................................................................................................................................................................... 6
3.1. Scenario ........................................................................................................................................................................................ 6
3.2. Use case Diagram ......................................................................................................................................................................... 6
3.3. Class Diagram ............................................................................................................................................................................... 7
3.3.1. Encapsulation ........................................................................................................................................................................ 7
3.3.2. Abstraction ............................................................................................................................................................................ 8
3.3.3. Inheritance ............................................................................................................................................................................ 9
3.3.4. Polymorphism ....................................................................................................................................................................... 9
4. Design Patterns .................................................................................................................................................................................. 10
4.1. Creational pattern ...................................................................................................................................................................... 11
4.2. Structural pattern .......................................................................................................................... Error! Bookmark not defined.
4.3. Behavioral pattern......................................................................................................................... Error! Bookmark not defined.
5. Conclusion ......................................................................................................................................................................................... 12
6. References ......................................................................................................................................................................................... 13

Table of Figures
Figure 1 - Use case diagram ........................................................................................................................................................................ 6
Figure 2 - Public access modifier example ............................................................................................................................................................... 7
Figure 3 - Private access modifier example ............................................................................................................................................................. 7
Figure 4 - Protected access modifier example ........................................................................................................................................................ 8
Figure 5 - Abstract function example 1 .................................................................................................................................................................... 8
Figure 6 - Abstract function example 2 .................................................................................................................................................................... 9
Figure 7 - Inheritance class example ........................................................................................................................................................................ 9
Figure 8 - Polymorphism example 1 ....................................................................................................................................................................... 10
Figure 9 - Polymorphism example 2 ....................................................................................................................................................................... 10
Figure 10 - Builder UML ............................................................................................................................................................................................ 12
1. Introduction
Nowadays, OOP and Design patterns are becoming a trend in the world of programmers. Object-Oriented Programming is a popular
programming method that appears most in the educational career of any programmer. Design Patterns are solution patterns in
software design, which provide customization and other essential abilities to the program. The concept of Object-Oriented
Programming and Design Patterns are explained in this report.

2. OOP general concepts


Object-oriented programming (OOP) is a fundamental programming paradigm that almost every developer has encountered at some
point in their career. For the majority of a programmer's educational career, OOP is taught as the normal approach to code. The
concepts of classes and objects are well-known in the OOP programming paradigm. It's used to break down a software program into
simple, reusable code blueprints that can then be utilized to construct individual instances of objects. Object-oriented programming
languages include JavaScript, C++, Java, and Python, among others (Prasanna, 2022).

Benefits of OOP

● Complex things are modeled as repeatable, simple structures in OOP.


● OOP objects are reusable and can be utilized in multiple programs.
● Polymorphism allows for class-specific behavior.
● Classes are easier to debug since they generally contain all relevant information.
● Encapsulation secures and safeguards information.

Disadvantages of OOP

● The program's size is larger than that of other programs.


● It took a long time to develop and is slower than other programs.
● It isn't appropriate for certain types of issues.
● It takes some time to adjust.

3. OOP scenario
3.1. Scenario
To have a better understanding of OOP general concepts, I will have an example of an employee program. In this scenario, you are a
boss of a toy shop, and with the employee program, you could add full-time employees, part-time employees, or a sale. Another
option is to view all of the current employees.

3.2. Use case Diagram

Figure 1 - Use case diagram


This is a use-case diagram of this scenario, it shows that you could make an action of adding full-time employees, part-time
employees, sales, and display all employees.

3.3. Class Diagram

3.3.1. Encapsulation

Encapsulation is the practice of keeping fields within a class private, then providing access to those fields via public methods.
Encapsulation is a protective barrier that keeps the data and code safe within the class itself. We can then reuse objects like code
components or variables without allowing open access to the data system-wide. (Biniasz, 2021)

There are 3 access modifiers we used in this program. Here are some examples of them:

Public: Public properties can be accessed from anywhere in the project

Figure 2 - Public access modifier example

Private: Private properties can only be accessed within the same class

Figure 3 - Private access modifier example


Protected: Protected properties can only be accessed within the same and the inherited class from the owner class

Figure 4 - Protected access modifier example

3.3.2. Abstraction

Abstraction uses simple things to represent complexity. We all know how to turn the TV on, but we don’t need to know how it works
in order to enjoy it. In Java, abstraction means simple things like objects, classes, and variables represent more complex underlying
code and data. This is important because it lets you avoid repeating the same work multiple times. (Biniasz, 2021)

Figure 5 - Abstract function example 1

In this example, we can see that there is nothing in the function Salary(). I only declared and left it there.
Figure 6 - Abstract function example 2

But in the sub-classes, I declared an action to it.

3.3.3. Inheritance

Inheritance is A special feature of Object-Oriented Programming in Java; Inheritance lets programmers create new classes that share
some of the attributes of existing classes. Using Inheritance lets us build on previous work without reinventing the wheel. (Biniasz,
2021)

Figure 7 - Inheritance class example

In this example, class Partime is inherited from class Full-time, which will make Partime a sub-class of Fulltime class.

3.3.4. Polymorphism

Polymorphism allows programmers to use the same word in Java to mean different things in different contexts. One form of
polymorphism is method overloading. That’s when the code itself implies different meanings. The other form is method overriding.
That’s when the values of the supplied variables imply different meanings. (Biniasz, 2021)
Figure 8 - Polymorphism example 1

Figure 9 - Polymorphism example 2

In these examples, there are 2 functions that have the same name, inherited from another class but they override the function from
the owner.

4. Design Patterns
A design pattern is a generic, repeatable solution to general problems that software developers faced during software development.
A design pattern isn't a finished design that can be turned into code right away. It's a description or template for solving an issue
that may be applied to a variety of scenarios. There are 23 different design patterns that can be divided into three groups:
Creational, Structural and Behavioral patterns (TutorialsPoint, 2022).

● Creational Patterns: Instead of instantiating objects directly with the new operator, these design patterns give a mechanism
to construct objects while obscuring the creation logic. This allows the software to decide which items are required for a
specific use case with greater flexibility. The creational pattern includes abstract factory, builder, factory method, prototype,
and singleton.
● Structural Patterns: Class and object composition are the focus of these design patterns. The concept of inheritance is used
to create interfaces and explain how objects can be combined to create new functions. The structural pattern contains an
adapter, bridge, composite, decorator, facade, flyweight, and proxy.
● Behavioral Patterns: These design patterns are focused on object communication in particular. The behavioral pattern
includes the chain of responsibility, command, interpreter, mediator, memento, observer, state, strategy, template method,
and visitor.

4.1. Creational patterns


Builder
Builder is a design pattern that allows users to build complicated objects in steps. Using the same building code, many types and
representations of an object can be created (Tyagi, 2019).

A house contains many different aspects such as types of walls, the number of floors, types of roofs, and different backyard settings
such as trees, pool, garden, and more. In the traditional approach, the House constructor will be containing these parameters, which
ends up with a large number of parameters. Additionally, any additional parameter will require further expansion of this hierarchy.
The problem can be addressed through a builder pattern which allows the parameter to be extracted out of its own class and moved
to a builder object.
Figure 10 - Builder UML

The figure above shows an example of a House Builder diagram. There are four classes including Director, Builder interface,
HouseBuilder, ApartmentBuilder and House. A house contains many factors; therefore, it has been extracted into a separate house
builder class instead of a House constructor with a large number of parameters.

The HouseBuilder and ApartmentBuilder classes include a set of methods for assembling various components of a house, such as
floors, roof, and backyard. The director is created for executing the construction steps in a particular order. The result will be sent to
the director through the makeHouse() operation and displayed on the screen.
5.Conclusion
In conclusion, the report has covered the concepts of Design Patterns and Object-Oriented programming, as well as gave detailed
examples of each concept. Such scenarios and diagrams were included in the examples of each conception. In addition, the
comparison of Design patterns and OOP has been analyzed and discussed on the relationship between these two programming
concepts.

6. References
Tyagi, A., 2019. Builder Design Pattern Using C#. [online] C-sharpcorner. Available at: <https://www.c-
sharpcorner.com/article/builder-design-pattern-using-c-sharp/> [Accessed 23 April 2022].

Prasanna, 2022. Advantages And Disadvantages Of OOP | What is OOP?, Objectives of OOP. [online] aplustopper. Available at:
<https://www.aplustopper.com/advantages-and-disadvantages-of-oop/#Disadvantages_Of_Oop> [Accessed 23 April 2022].

BINIASZ, K., 2021. What Are OOP Concepts in Java? How They Work and More. [online] Stackify. Available at:
<https://stackify.com/oops-concepts-in-java/> [Accessed 23 April 2022].

TutorialsPoint, 2022. Design Pattern - Overview. [online] TutorialsPoint. Available at:


<https://www.tutorialspoint.com/design_pattern/design_pattern_overview.htm> [Accessed 25 April 2022].

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy