0% found this document useful (0 votes)
13 views19 pages

1651 GCS210109 Assignment1

1651_GCS210109_Assignment1

Uploaded by

hien0979717071
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)
13 views19 pages

1651 GCS210109 Assignment1

1651_GCS210109_Assignment1

Uploaded by

hien0979717071
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/ 19

Higher Nationals in Computing

Unit 16: Advanced Programming


ASSIGNMENT 1

Learner’s name: Tran Quang Hien


ID: GCS210109
Class: GCS1003A
Subject code: 1651
Assessor name: NGUYEN NGOC TU

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 Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Tran Quang Hien Student ID GCS210109

Class GCS1003A Assessor name Nguyen Ngoc Tu

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:
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 2023

Unit Tutor Nguyen Ngoc Tu

Issue date Submission date

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 but should be
able to presents various characteristics of OOP (such as: encapsulation, inheritance, polymorphism, override,
overload, etc.).
The second task is to introduce some design patterns (including 3 types: creational, structural and behavioral)
to audience by giving real case scenarios, corresponding patterns illustrated by UML class diagrams.
To summarize, you should analyze the relationship between the object-orientated paradigm and design
patterns.

The presentation should be about approximately 20-30 minutes and it should be summarized of the team report.

Learning Outcomes and Assessment Criteria

Pass Merit Distinction

LO1 Examine the key components related to the object-orientated


programming paradigm, analysing design pattern types

P1 Examine the M1 Determine a D1 Analyse the


characteristics of the design pattern from relationship
object-orientated each of the between the object-
paradigm as well as creational, structural orientated
the various class and behavioural paradigm and
relationships. pattern types. design patterns.

LO2 Design a series of UML class diagrams

P2 Design and build M2 Define class D2 Define/refine


class diagrams using diagrams for specific class
a UML tool. design patterns diagrams derived
using a UML tool. from a given code
scenario using a
UML tool.
Table of Contents
1. Introduction.......................................................................................................................................... 6
2. Examine the characteristics of the object-orientated paradigm as well as the various class relationships
(P1) .......................................................................................................................................................... 6
2.1 Object – Oriented Programming (OOP) ......................................................................................................... 6
2.1.1 Definition ............................................................................................................................................................................ 6
2.1.2 The benefits of OOP ............................................................................................................................................................ 6
2.1.3 Criticism of OOP .................................................................................................................................................................. 7
2.2 General concepts of OOP .............................................................................................................................. 7
2.2.1 Object .................................................................................................................................................................................. 7
2.2.2 Class .................................................................................................................................................................................... 7
2.2.3 Encapsulation ...................................................................................................................................................................... 7
2.2.4 Inheritance .......................................................................................................................................................................... 8
2.2.5 Polymorphism ..................................................................................................................................................................... 8
2.2.6 Abstraction .......................................................................................................................................................................... 9

3. Design and build class diagrams using a UML tool (P2) ......................................................................... 10
3.1 OOP scenario ............................................................................................................................................. 10
3.1.1 Scenario............................................................................................................................................................................. 10
3.1.2 Use case Diagram .............................................................................................................................................................. 11
3.1.3 Class Diagram .................................................................................................................................................................... 14

4. Conclusion .......................................................................................................................................... 17
REFERENCES ........................................................................................................................................... 18
ASSIGNMENT 1 ANSWERS
1. Introduction
In this assignment, I will specify the properties of the object-oriented programming paradigm by applying
object-oriented research and design to a particular circumstance. Certain OOP traits should be addressed even
though the issue is not urgent. By employing real-world case studies and relevant trends illustrated with UML
class diagrams, the second goal is to inform the audience about some design trends. Last but not least, I'll show
how design patterns and OOP relate to one another.
2. Examine the characteristics of the object-orientated paradigm as well as the various class relationships
(P1)
2.1 Object – Oriented Programming (OOP)
2.1.1 Definition
A programming paradigm known as object-oriented programming arranges software around data or objects
rather than functions and logic. A data field with unique characteristics and behavior is called an object. Mobile
apps as well as manufacturing and design software benefit greatly from this type of development. Different
benefits of OOP incorporate code reusability, adaptability, and proficiency.

Figure 1: Object – Oriented Programming


(Source: https://bumbii.com/tong-quan-ve-lap-trinh-huong-doi-tuong-oop-object-oriented-programming/)
2.1.2 The benefits of OOP
Object-Oriented Programming (OOP) has several benefits, including:
- Modularity: OOP permits you to figure out down your code into more modest, more sensible pieces called
objects. This makes it more straightforward to peruse, comprehend, and keep up with your code.
- Reusability: OOP permits you to reuse code by making objects that can be utilized in various pieces of your
program, or even in various projects out and out
- Encapsulation: OOP permits you to exemplify data and methods inside an article, and that implies that the
inner functions of the item can be stowed away from the remainder of the program. This assists with
safeguarding the uprightness of the data and guarantees that it is just gotten to and changed in a controlled
manner.
- Inheritance: OOP permits you to make new classes in view of existing classes. This is called inheritance, and
it permits you to reuse code and make more specific classes without revamping all that without any preparation.

P ag e |6
- Polymorphism: OOP permits you to involve similar strategy or property in various ways relying upon the
setting where it is utilized. This is called polymorphism, and it makes it more straightforward to compose
adaptable, reusable code.
2.1.3 Criticism of OOP
- Complexity: OOP can be more complex than other programming paradigms, especially for amateurs. It
presents new ideas like inheritance, polymorphism, and epitome, which can be challenging to comprehend and
apply accurately.
- Overuse of inheritance: Inheritance is a strong element of OOP, yet it can likewise prompt code that is hard
to keep up with and comprehend. Now and again, engineers might overuse inheritance, making complex class
pecking orders that are difficult to explore.
- Tight coupling: OOP can prompt tight coupling between objects, which can make it hard to alter or expand
code. Changes to one piece of the code can have unseen side-effects on different pieces of the code.
- Performance: OOP can be slower than other programming paradigms due to the above of dynamic dispatch
and virtual capability calls.
- Not suitable for all types of problems: OOP isn't generally the best methodology for tackling specific types of
problems, for example, those that don't include information control or require superior performance.
2.2 General concepts of OOP
2.2.1 Object
An object is a true entity that has attributes, conduct, and properties. It is alluded to as an occasion of the class.
It contains part functions, factors that we have characterized in the class. It consumes space in the memory.
Various objects have various states or attributes, and ways of behaving.
In OOP, objects comprise of 2 main components:
- Attributes: are the data and characteristics of the object
- Methods: are the ways of behaving that the object can perform
To make it simpler to envision, we have a genuine illustration of an object that is a cell phone. This object will
have:
- Attributes: variety, memory, operating system, …
- Methods: calling, taking photographs, messaging, recording, ...
2.2.2 Class
Class is an abstraction of the object. Objects with comparable properties are gathered into a class. The class
will likewise incorporate two snippets of data: properties and methods. An object will be treated as an occasion
of the class.
Proceeding with the model in the object segment above, we have a cell phone class comprising of 2 parts:
- Credits: variety, memory, operating system…
- Methods: calling, taking photographs, messaging, recording...
- Objects of this class can be iPhone, Samsung, Oppo, Huawei, and so on.
2.2.3 Encapsulation
Encapsulation is the method involved with concealing the execution subtleties of an object from the rest of the
world. This implies that the object's interior state must be gotten to through an obvious connection point, which
gives a degree of abstraction.

P ag e |7
Figure 2: Example of Encapsulation
(Source: https://www.javatpoint.com/what-is-object-oriented-programming)
2.2.4 Inheritance
The technique of building new classes from old ones is called inheritance. The ability to assign relationships
and subclasses allows developers to reuse similar functionality while yet retaining a distinct hierarchy. This
attribute of OOP speeds up development and provides more accuracy by requiring a more in-depth investigation
of the data.

Figure 3: Example of Inheritance


(Source: https://www.javatpoint.com/what-is-object-oriented-programming)
The figure above demonstrates that when using inheritance, the other methods in the parent class only need to
be written once, and the subclasses can continue to inherit. Editing errors will be avoided, and reusability will
enhance.
2.2.5 Polymorphism
Polymorphism is an expression of Greek beginning, converted into Vietnamese signifying "a name with various
structures and shapes".
In other words, an object has many structures or a name with a wide range of functions. "Poly" signifies
numerous, and "morph" signifies structures. Polymorphism gives the capacity to execute various classes with
a similar name.
As referenced above, polymorphism in C# manages various classes with a similar name, which are connected
P ag e |8
with each other. This is a significant concept in object-oriented programming after encapsulation and
inheritance.

Figure 4: Example of Polymorphism


(Source: https://www.javatpoint.com/what-is-object-oriented-programming)
There are basically 2 types of polymorphism in C#, including:
- Static polymorphism / Compile Time.
- Dynamic/Runtime polymorphism.
Static Polymorphism in C# (or Compile Time)
Static polymorphism (or Compile Time) in C# is otherwise called Early Binding. Method overloading is a
genuine illustration of static polymorphism.
In overloading, the method/function has a similar name yet a different signature. It is otherwise called compile
time polymorphism in light of the fact that the choice on which method is called is finished at compile time.
Overloading is an idea where methods have similar names as various arrangements of parameters.
Here the compiler checks the quantity of parameters passed and the sort of parameters, and afterward settles on
a choice on which method to call. If assuming no method is found, it will toss an error.
Dynamic Polymorphism in C# (or Runtime Polymorphism)
Dynamic Polymorphism or Runtime Polymorphism is otherwise called Late Binding. Where method name and
method signature (number of boundaries and boundary type ought to be same however may have different
execution). Overriding is a genuine illustration of dynamic polymorphism.
Overriding can be finished utilizing inheritance. With overriding method, base class and determined class can
have same method name and another thing. The compiler doesn't know about the method accessible to abrogate
the function, so it won't return a blunder while compiling. The compiler will decide which method to call at
runtime and assuming no method is found it will toss an error.
2.2.6 Abstraction
Abstraction is one of the four significant characteristics of object-oriented programming languages (OOP). Its
fundamental objective is to diminish intricacy by hiding subtleties that are not straightforwardly connected with
the client (the client here isn't the end client however the software engineer). That permits the client to in any
case play out the important work in light of a gave abstract entity without understanding or in any event,
pondering all the intricacy prowling inside.
In OOP, Abstraction can be isolated into 2 levels (2 realms)
- The first realm: Data and a few methods (methods) that are not required to have been uncovered external will
be remembered for the class and indicate the entrance determination as private (or safeguarded). Those data or

P ag e |9
methods won't be open from beyond that class. In this realm abstraction makes the code more obvious as it
centers around the core highlights/activities and not on the unimportant subtleties. What's more, it likewise
makes the program simple to keep up with, restricting errors because of unpredictable and wrong data access.
At this level, you can think about Abstraction = Encapsulation + Data Hiding.
- The second realm: In this realm we perform abstraction from the plan stage to the coding stage. In the plan
configuration stage, we will zero in on expressing "what" - what a module or class will do, not on "how" - the
way things are finished. The consequence of this plan step will be a supposed point of interaction. Classes (or
modules) will work with one another through the point of interaction, without knowing one another explicitly.

Figure 5: Example of Abstraction


(Source: https://www.javatpoint.com/what-is-object-oriented-programming)
3. Design and build class diagrams using a UML tool (P2)
3.1 OOP scenario
3.1.1 Scenario
The library of the University of Greenwich Vietnam has imported countless books of all types. The school's
library has consistently controlled and overseen books by manual HR, presently they decided to build an
effective book management software and I'm the developer appointed to do this undertaking. For this project
of the library, I decided to choose an object-oriented programming arrangement combined with the C#
programming language to help software implementation. The justification for this choice of mine is because:
- Object-oriented programming enjoys extraordinary benefits in the software improvement process such as
security, simplicity of the board and advancement, and enhancement generally speaking.
- The C# programming language is one of the most well-known object-oriented programming dialects on the
planet. With the backing from Microsoft, C# will be the confided in language in software advancement that I
choose.

Figure 6: C Sharp programming language


(Source: https://source.vn/ngon-ngu-lap-trinh-csharp/)
The software will include the following main functions:

P a g e | 10
- Add, delete, edit books.
- Print the entire book onto the screen.
- Search for books.
- Borrow books and return books.
Software requirements include:
- Students and faculty can both view information and search for book information.
- Faculty and students can borrow books.
- The librarian will be in charge of returning books as well as adding, deleting, and editing book metadata.
- An intuitive user interface.
- Has crystal-clear transparency, solid security, and the potential for future growth.
3.1.2 Use case Diagram

Figure 7: Use case diagram


Explanation:
Specification for readers
- Specification name: Find book (Teacher or Student).
Specification target: Client can search book by name or Id.
Description: The client selects the book search; then the search message panel appears requesting to enter the

P a g e | 11
name or book ID. In the wake of entering, the system does the undertaking of looking and yielding book
information according to the id (name) entered.

- Specification name: Borrow book (Teacher or Student).


Target specification: The client can borrow books and timetable return arrangements (no more than 14 days).
Description: The client selects the book to borrow, then enters the book he needs to borrow and individual
information to borrow. After getting the information, the system will begin counting down time to return the
book.

- Specification Name: View the whole book (Teacher or Student).


Specification target: Permit the client to see all current books in the library.
Description: The client selects the item to see all books in the program, all the information’s of the book will
be displayed on the screen for the client.
Specification for Librarian
- Specification name: Book search (Librarian).
Specification target: Librarians can search books by name or Id.
Description: The librarian selects the book search; then the search message panel appears requesting to enter
the name or book ID. In the wake of entering, the system does the undertaking of looking and yielding book
information according to the id (name) entered.

- Specification name: View full book (Librarian).


Specification target: Permit librarians to view all current books in the library.
Description: The librarian selects the item to see all books in the program, all the information’s of the book will
be displayed on the screen for the librarian.

- Specification name: Add book (Librarian).


Specification target: Permit librarians to add new books to the library.
Description: The librarian decides to add another book in the program, then adds the fundamental information
of the book and snaps save. When saved, the book will be added and will be shown if necessary.

- Specification name: Delete book (Librarian).


Specification target: Permit librarians to delete existing books in the library.
Description: The librarian decides to delete books in the program and enter the book id to delete, then, at that
point, press delete. The program will find the right books entered by the librarian and delete them and afterward
tell them that they have been deleted.

- Specification name: Edit book information (Librarian).


Specification target: Permit librarians to edit information about books currently in the library.
Description: The librarian decides to edit book information in the program, then pass in the book id to edit. The
book information that matches the info id will leap out and the librarian can address it, then, at that point, press

P a g e | 12
update, the new information will be saved in the program.
Librarian capabilities:
- Librarians can add books.
- Librarians can delete books.
- Librarians can edit book information.
- The librarian carries out the role of returning books back.
- Librarians can search for book information.
- Librarians can view information of accessible books.
Use case:
Use case 1: Main Screen
Scope User Goal

Goal in Context Present a main menu form which one can access the
various functions of the library management system
Primary Actor User and Admin
User: Wants to get a specific book for certain period
of time
Stakeholders
Admin: Wants to keep the record of all books (issued
or returned) and maintains the record
Run Library Management Software and entered
Preconditions password is correct

Triggers A previous command completes successfully

The Library Management System waits for user input


Success Guarantee when main menu is on the screen

Use case 2: Search Books


Scope User Goal
Present a form to the admin/user to allow him to
Goal in Context
search the Books
Primary Actor User and Admin

Stakeholders Wants to search the record of the Require Book

None
Preconditions
Triggers Admin/User selects Search Books option from the
Books Catalogue menu.

P a g e | 13
Library Management Software shows the
Success Guarantee information of the required Book

Use case 3: View Books


Scope User Goal

Goal in Context Present a form to the admin /user to view all Books

Primary Actor User and Admin

Stakeholders Wants to view all Books that are in the library

Preconditions None
Admin/User selects View Books option from the
Triggers
Books Catalogue menu.
Library Management Software shows the table that
Success Guarantee contains all Books that are in the library.

Use case 4: Returned Books


Scope User Goal
Present a form to the admin to allow him to add
Goal in Context
record of the returned Books
Primary Actor Admin

Stakeholders Admin: Wants to add record of the different returned


Books
Preconditions The User entered correct the password
Admin selects Add returned Books option from the
Triggers
borrow Books menu
The record of the returned Books is added to the
Success Guarantee Library Management Software

3.1.3 Class Diagram

P a g e | 14
Figure 8: Class diagram
Explanation:
This library management program includes 5 main classes: Librarian, Book, User, Teacher, and Student.
Class User:
As the parent class of the two classes teacher and students, this class creates a frame for two sub -classes and
provides execution methods for the subclass (using inheritance in object-oriented programming). Two sub-
classes are teachers and students who can overwrite the method showinfo () inside the user class to suit the
subclass's properties (this is known as polymorphic application in object-oriented programming).

P a g e | 15
Figure 9: Class User

Figure 10: Class Teacher and Student


Class Book:
This class creates a frame with book objects and a variety of background information that is similar. To perform
tasks for book objects, this class book also links with two classes, Librarian and User. Because object-oriented
programming is abstract, neither the classes Librarian nor User need to be concerned with the specifics of the
class book to use it. Class Book can now be viewed as an abstract data type for the classes of User and Librarian.

Figure 11: Class Book


Class Librarian:
The Librarian object is constructed using this class as its base. This class creates an internal book object and
uses it to carry out tasks for which the librarian is responsible such as adding, deleting, and editing books.

P a g e | 16
Figure 12: Class Librarian
4. Conclusion
A suitable and appropriate approach to use for the project of the Greenwich School Library is to apply UML
design of the Use Case Diagram and Class Diagram above as well as the theory of object-oriented
programming. Through this, I was able to improve my capacity to use object-oriented programming for any
project. My evaluation is that the requirements established for the project are fully compatible with the system
design, organizational strategy, and object-oriented programming characteristics.

P a g e | 17
REFERENCES
GILLIS, A. S. 2023. object-oriented programming (OOP) [Online]. Available:
https://www.techtarget.com/searchapparchitecture/definition/object-oriented-programming-OOP [Accessed
19 April 2023].
HALF, R. 2023. 4 Advantages of Object-Oriented Programming [Online]. Available:
https://www.roberthalf.com/blog/salaries-and-skills/4-advantages-of-object-oriented-programming [Accessed
19 April 2023].
HERRITY, K. 2023. What Is Object-Oriented Programming (OOP)? A Complete Guide [Online]. Available:
What Is Object-Oriented Programming (OOP)? A Complete Guide [Accessed 19 April 2023].
JANSSEN, T. 2017. OOP Concept for Beginners: What is Inheritance? [Online]. Available:
https://stackify.com/oop-concept-inheritance/ [Accessed 19 April 2023].
JANSSEN, T. 2021. OOP Concepts for Beginners: What is Polymorphism [Online]. Available:
https://stackify.com/oop-concept-polymorphism/ [Accessed 19 APril 2023].
JANSSEN, T. 2022. OOP Concept for Beginners: What is Encapsulation [Online]. Available:
https://stackify.com/oop-concept-for-beginners-what-is-encapsulation/ [Accessed 19 April 2023].
JANSSEN, T. 2023. OOP Concept for Beginners: What is Abstraction? [Online]. Available:
https://stackify.com/oop-concept-abstraction/ [Accessed 19 April 2023].
TEAM, G. 2023a. Advantages and Disadvantages of OOP [Online]. Available:
https://www.geeksforgeeks.org/benefits-advantages-of-oop/ [Accessed 19 April 2023].
TEAM, G. 2023b. Difference Between Method Overloading and Method Overriding [Online]. Available:
https://www.geeksforgeeks.org/difference-between-method-overloading-and-method-overriding-in-java/
[Accessed 20 April 2023].
TEAM, J. 2023c. What is Object-Oriented Programming? [Online]. Available:
https://www.javatpoint.com/what-is-object-oriented-programming [Accessed 19 April 2023].

P a g e | 18

You might also like