Higher Nationals: Internal Verification of Assessment Decisions - BTEC (RQF)
Higher Nationals: Internal Verification of Assessment Decisions - BTEC (RQF)
Higher Nationals
Internal verification of assessment decisions – BTEC (RQF)
Programme title
Assessor Internal
Verifier
Unit 20 – Advance Programming
Unit(s)
Assignment title
S.M.Nipuna Madhuranga Samarakoon
Student’s name
List which assessment criteria Pass Merit Distinction
the Assessor has awarded.
Internal
Date
Verifier
signature
Programme Leader
Date
signature (if required)
LO3 Discuss the importance and dynamics of working within a team and the impact of team
working in different environments
Pass, Merit & P5 P6 M4 D3
Distinction Descripts
LO4 Examine the need for Continuing Professional Development (CPD) and its role within the
workplace and for higher level learning
Pass, Merit & P7 P8 M5 D4
Distinction Descripts
Resubmission Feedback:
* Please note that grade decisions are provisional. They are only confirmed once internal and external moderation has taken place and grades
decisions have been agreed at the assessment board.
Assignment Feedback
Formative Feedback: Assessor to Student
Action Plan
Summative feedback
General Guidelines
1. A cover page or title page should be attached to your assignment. Use page 1 of this assignment
brief as your cover page and make sure all details are accurately filled.
2. The entire assignment brief should be attached as the first section of your assignment.
3. The assignment should be prepared using a word processing software.
4. The assignment should be word processing in an A4 sized paper.
5. Allow 1” margin on top, bottom and right sides of the paper and 1.25” on the left side (for binding).
1. The font size should be 12 point, and should be in the style of Time New Roman.
2. Set line spacing to 1.5. Justify all paragraphs.
3. Ensure that all headings are consistent in terms of size and font style.
4. Use footer function on the word processor to insert your name, unit, assignment no, and page
number on each page. This is useful if individual sheets get detached from the submission.
5. Use the spell check and grammar check function of the word processing application to review the
use of language on your assignment.
Important Points:
1. Carefully check carefully the hand in date and the instructions given with the assignment. Late
submissions will not be accepted.
2. Ensure that sufficient time is spent to complete the assignment by the due date.
3. Do not wait till the last minute to get feedback on the assignment. Such excuses will not be accepted
for late submissions.
4. You must be responsible for efficient management of your time.
5. If you are unable to hand in your assignment on time and have valid reasons such as illness, you
may apply (in writing) for an extension.
6. Failure to achieve at least a PASS grade will result in a REFERRAL grade.
7. Non-submission of work without valid reasons will lead to an automatic REFERRAL. You will
then be asked to complete an alternative assignment.
8. If you use other people’s work or ideas in your assignment, it must be properly referenced, using
the HARVARD referencing system, in your text or any bibliography. Otherwise, you’ll be found
guilty of committing plagiarism.
9. If you are caught plagiarising, your grade will be reduced to a REFERRAL or at worst, you could
be excluded from the course.
Student Declaration
I hereby, declare that I know what plagiarism entails, namely to use another’s work and to present it as
my own without attributing the sources in the correct form. I further understand what it means to copy
another’s work.
[email protected] 21/07/2019
Student’s Signature: Date:
(Provide E-mail ID) (Provide Submission Date)
Unit Tutor
Assignment Title
Issue Date
Submission Date
Submission format
The submission is in the form of an individual written report about. 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 an end list of
references using the Harvard referencing system. Please note that this is an activity-based
assessment where your document submission should include evidences of activities carried out
and of team working. To carry out activities given on the brief, you are required to form groups,
comprising not exceeding 15 individuals.
The recommended word count is 4,000–4,500 words for the report excluding annexures. Note
that word counts are indicative only and you would not be penalised for exceeding the word
count.
Learning Outcomes
By the end of this unit students will be able to:
LO1. Examine the key components related to the object-orientated programming
paradigm, analysing design pattern types.
LO2. Design a series of UML class diagrams.
Family Dental Care (FDC) is a leading up market dental surgery located in Kandy. It
provides all types of dental treatments to patients which include extractions, nerve fillings,
maxillofacial surgeries (i.e. surgeries involving jaw bone) and sophisticated dental implants.
It is visited by prominent dentists and dental consultants with post graduate qualifications,
some of whom are working at the Faculty of Dental Science at the University of Peradeniya.
Patients consult doctors by appointment. On their first visit, patients are required to register by
entering their personal details such as name, address, national identity card number and contact
number. A small fee is charged from the patient during registration. A separate fee is charged
for each treatment given.
Doctors too must get registered at FDC by providing personal details such as name, address,
date of birth, national ID number and contact number. In addition, consultants must provide the
name of their post graduate qualification along with the country of the University that granted
it and ordinary dentists should indicate the number of years of experience.
FDC consists of four fully equipped surgery rooms so that four patients can be accommodated
at any given time. FDC also contains a dental scan room which can be attended by one patient
at a time. The dental scan machine is operated by one of the dentists of the FDC facility.
Normally, a dentist without appointments for a given time slot (say, between 5 PM and 6 PM)
is assigned to the machine by the manager. When that time slot finishes, another doctor who is
free will be assigned.
The staff of FDC is made up of a manager, four nurses (one for each of the four surgery rooms)
and a receptionist who handles registrations and appointments.
An information system is required to keep track of patients, doctors, appointments, treatments
given to patients and payments. The system must also maintain information about the staff. It
has been decided to use an object oriented approach to design and implement the system.
Task 1
Briefly describe the following Object oriented concepts. Provide diagrams and code snippets to
supplement your explanations. (LO 1)
i) Class
ii) Object
iii) Message
iv) Encapsulation
Task 2
Design a detailed UML class diagram for the Family Dental Care system. Your solution should
demonstrate all three inter-class relationships, namely Association, Inheritance and
Aggregation/composition. The classes should include attributes and methods. (LO 2)
Task 3
i) Find one occurrence of inheritance (i.e. generalization) from your class diagram
and implement it using a suitable object oriented language. Your implementation
must cover the super class and at least two sub-classes. (LO 1)
ii) Explain the term “Polymorphism”. Demonstrate, with the aid of a code snippet, how
polymorphism can be achieved via method redefinition from the “inheritance” code
that you have produced in task 3 – (i). (LO 1)
iii) Find one occurrence of Aggregation/composition in your class diagram and
implement it using a suitable object oriented language. Your implementation must
cover both the “whole” class and component class. Include a main program that
demonstrates how components can be instantiated and stored in the whole. Provide
screen shots (in addition to source code) as evidence of program execution. (LO 1)
iv) At FDC, dentists work at the scan machine in turns. At any given time, a dentist may
be either treating a patient or operating the dental scanner. In other words, a doctor
plays two roles at FDC: Treating patients and operating Dental Scanner. If we
send a getDetails() message to a dentist object, the response varies depending on
his/her role at the moment. Which object oriented feature would enable this to be
realized? Provide a detailed explanation and supplement it with appropriate UML
diagrams. Provide an implementation for the design using a suitable object oriented
language. Provide screen shots and source code listing as evidence of program
execution. (LO 1) (LO 2)
Task 4
i) What is a “Design pattern” ? How are they documented? How would design
patterns be useful to computer programmers? (LO 1)
ii) FDC owns a very expensive, state of the art dental scan machine (a device far
superior to a traditional dental X-ray machine) manufactured by Toshiba, Japan. FDC
will be owning just one such machine in the foreseeable future. When modeling and
implementing FDC system in software, you must ensure that only one instance of
that machine is created. Which design pattern could come to your assistance? Justify
your answer. Provide a UML diagram and an implementation for the pattern you
have recommended. You may include suitable attributes for the machine such as
serial number, make, country of origin and cost. Your implementation should allow
the user to enter details of the dental scanner and create the sole instance of that
machine. Any attempt to create more than one instance of the scanner must be
prevented. Provide screen shots and source code listing as evidence of program
execution.
(LO 2) (LO 3) (LO 4)
iii) The treatments given to patients at FDC can be of two types: elementary and
complex. An elementary treatment is a single procedure such as a simple extraction
or a dental filling which usually requires a single visit.
iv) Patients who need dental scans are kept in a First In First Out queue. Assume that
you have found an already developed Queue container in a software library. It
provides standard queue operations to insert and remove data (known as enque and
deque respectively). However, you need some specific operations such as search() to
look up a particular patient and showAll() to list all the patients in the queue. These
additional operations are not provided by the library unit. Which design pattern
would enable you to obtain the additional functionality required by the queue? Justify
your answer. Supplement your answer with a UML class diagram. Coding is NOT
required. (LO 2) (LO 4)
Contents
Task 1 .......................................................................................................................................................... 17
OOP Concepts ......................................................................................................................................... 17
1. Class .................................................................................................................................................... 19
2. Inheritance .......................................................................................................................................... 19
Output: ................................................................................................................................................ 21
3. Objects ................................................................................................................................................ 21
4. Abstraction .......................................................................................................................................... 21
5. Encapsulation ...................................................................................................................................... 21
6. Polymorphism ..................................................................................................................................... 21
Message .................................................................................................................................................. 22
Task 2 .......................................................................................................................................................... 22
Task 3 .......................................................................................................................................................... 24
What is Inheritance? ............................................................................................................................... 24
Types of Inheritance ............................................................................................................................... 24
Single Inheritance: .............................................................................................................................. 24
Multiple Inheritance: .......................................................................................................................... 24
Multilevel Inheritance: ........................................................................................................................ 25
Inheritance in Java .............................................................................................................................. 25
Java Inheritance Syntax:...................................................................................................................... 26
Java Inheritance Example.................................................................................................................... 26
Super Keyword .................................................................................................................................... 27
Super Class – Employee ...................................................................................................................... 28
Sub classes .......................................................................................................................................... 29
3.2 Polymorphism ................................................................................................................................... 29
3.4 Aggregation / Composition ............................................................................................................... 31
Aggregation ......................................................................................................................................... 31
Aggregation Example in Java .............................................................................................................. 31
Why we need Aggregation? ................................................................................................................ 31
Composition ........................................................................................................................................ 31
Aggregation vs Composition ............................................................................................................... 32
3.5 getDetails() .................................................................................................................................... 32
Polymorphism ..................................................................................................................................... 32
Task 4 .......................................................................................................................................................... 33
sage of Design Pattern ............................................................................................................................ 33
Common platform for developers .......................................................................................................... 33
Best Practices ...................................................................................................................................... 34
Types of Design Patterns ........................................................................................................................ 34
Why are Design Patterns Important? ..................................................................................................... 34
Detailed answers:................................................................................................................................ 34
4.2 Design pattern could come to assistance & UML diagram and an implementation for the pattern
recommended......................................................................................................................................... 36
Singleton design pattern ......................................................................................................................... 36
Structure ............................................................................................................................................. 36
4.3 Suitable Design pattern for handling this requirement & specific UML class diagram and
Implement design ................................................................................................................................... 38
Adapter Pattern ...................................................................................................................................... 38
Adapter Pattern ..........................................................................Ошибка! Закладка не определена.
Class Diagram: ..................................................................................................................................... 39
Object Adapter Vs Class Adapter ........................................................................................................ 39
Advantages:......................................................................................................................................... 40
Disadvantages: .................................................................................................................................... 40
4.4 Design pattern enable to obtain the additional functionality required by the queue Supplement
your answer with a UML class diagram .................................................................................................. 41
Iterator Pattern ................................................................................................................................... 41
Task 1
OOP Concepts
Object Oriented programming is a programming style which is associated with the concepts like
class, object, Inheritance, Encapsulation, Abstraction, Polymorphism.
1. Class
A class is a collection of method and variables. It is a blueprint that defines the data and behavior
of a type.
Let’s take Human Being as a class. A class is a blueprint for any functional entity which defines
its properties and its functions. Like Human Being, having body parts, performing various
actions.
We can define a class using the class keyword and the class body enclosed by a pair of curly
braces, as shown in the following example:
using System;
namespace name
{
public class SampleHelloWorld
Figure 3author develop
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
2. Inheritance
Inheritance is a feature of object-oriented programming that allows code reusability when a class
includes property of another class. Considering HumanBeing a class, which has properties like
hands, legs, eyes, mouth, etc, and functions like walk, talk, eat, see etc.
Man and Woman are also classes, but most of the properties and functions are included in
HumanBeing. Hence, they can inherit everything from class HumanBeing using the concept of
Inheritance. Here is a code example:
Figure 4Inheritance
Output:
3. Objects
My name is Yann, and I am an instance/object of class Man. When we say, Human Being, Man
or Woman, we just mean a kind, you, your friend, and I. We are the forms of these classes. We
have a physical existence while a class is just a logical definition. We are the objects.
4. Abstraction
Abstraction means, showcasing only the required things to the outside world while hiding the
details. Continuing our example, Human Being’s can talk, walk, hear, eat, but the details of the
muscles mechanism and their connections to the brain are hidden from the outside world.
The concept of abstraction focuses on what an object does, instated of how an object is
represented or “how it works.” Thus, data abstraction is often used for managing large and
complex programs.
5. Encapsulation
Encapsulation means that we want to hide unnecessary details from the user. For example, when
we call from our mobile phone, we select the number and press call button. But the entire
process of calling or what happens from the moment we press or touch the call button to the
moment we start having a phone conversation is hidden from us.
6. Polymorphism
Polymorphism is a concept, which allows us to redefine the way something works, by either
changing how it is done or by changing the parts used to get it done. This can be done in two
ways, overloading and overriding.
If we walk using our hands, and not legs, here we will change the parts used to perform
something. Hence this is called Overloading.
(blog.usejournal, 2018)
Message
Message passing, in computer terms, refers to the sending of a message to a process which can be an
object, parallel process, subroutine, function or thread. This message can be used to invoke another
process, directly or indirectly. Message passing is especially useful in object-oriented programming
(OOP) and parallel programming when a single message (in the form of a signal, data packet
String user_name;
String user_type;
Dashboard dbord = new Dashboard(user_name, user_type);
Task 2
Task 3
What is Inheritance?
Inheritance is a mechanism in which one class acquires the property of another class. For
example, a child inherits the traits of his/her parents. With inheritance, we can reuse the fields
and methods of the existing class. Hence, inheritance facilitates Reusability and is an important
concept of OOPs.
Types of Inheritance
There are Various types of inheritance in Java:
Single Inheritance:
In Single Inheritance one class extends another class (one class only).
Figure 76author
(authordevelop
developed)
In above diagram, Class B extends only Class A. Class A is a super class and Class B is a Sub-class.
Multiple Inheritance:
In Multiple Inheritance, one class extending more than one class. Java does not support multiple
inheritance.
Multilevel Inheritance:
In Multilevel Inheritance, one class can inherit from a derived class. Hence, the derived class
becomes the base class for the new class.
Inheritance in Java
In Java, when an "Is-A" relationship exists between two classes we use Inheritance
The parent class is termed super class and the inherited class is the sub class
The keyword "extend" is used by the sub class to inherit the features of super class
Inheritance is important since it leads to reusability of code
Super Keyword
The keyword super can be used to access any data member or methods of the parent class.
Syntax:
In this example from the scenario Employee class and Doctor, Nurse, Consultant, Receptionist are an
occurrence of inheritance.
Sub classes:
(guru99, 2018)
3.2 Polymorphism
Polymorphism is the ability of an object to take on many forms. The most common use of
polymorphism in OOP occurs when a parent class reference is used to refer to a child class
object.
Any Java object that can pass more than one IS-A test is considered to be polymorphic. In Java,
all Java objects are polymorphic since any object will pass the IS-A test for their own type and
for the class Object.
It is important to know that the only possible way to access an object is through a reference
variable. A reference variable can be of only one type. Once declared, the type of a reference
variable cannot be changed.
The reference variable can be reassigned to other objects provided that it is not declared final.
The type of the reference variable would determine the methods that it can invoke on the object.
A reference variable can refer to any object of its declared type or any subtype of its declared
type. A reference variable can be declared as a class or interface type.
(tutorialspoint, 2018)
In this example employee class (base class) use has the insert object. And Doctors too. In the doctor class
(child class) override the insert object.
Aggregation
For example consider two classes Student class and Address class. Every student has an address so
the relationship between student and address is a Has-A relationship. But if you consider its vice
versa then it would not make any sense as an Address doesn’t need to have a Student necessarily.
Lets write this example in a java program.
Student Has-A Address
To maintain code re-usability. To understand this lets take the same example again. Suppose
there are two other classes College and Staff along with above two classes Student and Address. In
order to maintain Student’s address, College Address and Staff’s address we don’t need to use
the same code again and again. We just have to use the reference of Address class while defining
each of these classes.
(beginnersbook, 2018)
Composition
Composition is a restricted form of Aggregation in which two entities are highly dependent on
each other.
Aggregation vs Composition
(geeksforgeeks, 2018)
3.5 getDetails()
Polymorphism
Generally, the ability to appear in many forms. In object-oriented programming, polymorphism refers to a
programming language's ability to process objects differently depending on their data type or class. More
specifically, it is the ability to redefine methods for derived classes. For example, given a base class
shape, polymorphism enables the programmer to define different area methods for any number of derived
classes, such as circles, rectangles and triangles. No matter what shape an object is, applying the area
method to it will return the correct results. Polymorphism is considered to be a requirement of any true
object-oriented programming language (OOPL).
(webopedia, 2019)
Task 4
A design pattern is a repeatable solution to a software engineering problem. Unlike most program-specific
solutions, design patterns are used in many programs. Design patterns are not considered finished
product; rather, they are templates that can be applied to multiple situations and can be improved over
time, making a very robust software engineering tool. Because development speed is increased when
using a proven prototype, developers using design pattern templates can improve coding efficiency and
final product readability.
(techopedia, 2019)
Design patterns represent the best practices used by experienced object-oriented software developers.
Design patterns are solutions to general problems that software developers faced during software
development. These solutions were obtained by trial and error by numerous software developers over
quite a substantial period of time.
(sourcemaking, 2018)
Design patterns provide a standard terminology and are specific to particular scenario. For
example, a singleton design pattern signifies use of single object so all developers familiar with
single design pattern will make use of single object and they can tell each other that program is
following a singleton pattern.
Best Practices
Design patterns have been evolved over a long period of time and they provide best solutions to
certain problems faced during software development. Learning these patterns helps
unexperienced developers to learn software design in an easy and faster way.
As per the design pattern reference book Design Patterns - Elements of Reusable Object-
Oriented Software , there are 23 design patterns which can be classified in three categories:
Creational, Structural and Behavioral patterns. We'll also discuss another category of design
pattern: J2EE design patterns.
Short: They help us solve recurring design problems. Note that : design patterns don’t solve the
problem themselves, they help us solve the problem.
Detailed answers:
Communication, Learning and Enhanced Insight:
Over the last decade design patterns have become part of every developer’s
vocabulary. This really helps in communication. One can easy tell another
developer on the team, “I’ve used Command pattern here” and the other developer
understands not just the design, but can also easily figure out the rationale behind
it. Design Patterns really help in learning, esp. when you are new on a project. Also
this helps in providing developers with better insight about parts of the application
or 3rd party frameworks they use.
The hard part about OO Design is finding the appropriate objects and decomposing
a system. One has to think about encapsulation, granularity, dependencies,
flexibility, performance, evolution, reusability and so on. They all influence
decomposition, often in conflicting ways. Design Patterns really helps identify less
obvious abstractions. These objects are seldom found during analysis or even the
early design, they’re discovered later in the course of making a design more flexible
and reusable.
One thing I struggle a lot with is finding the right level of abstraction and granularity. Design
patterns helps in coming up with objects with different levels of granularity that makes sense.
Identifying the right interface and the relationship between various interface is not a one-shot
activity. Usually it takes several iterations to identify the right composition of interfaces. Forget
interfaces, most of the times, coming up with a method signature can also be quite tricky. Design
Patterns really helps in this area.
How should we implement an Object? Given an interface there could be multiple concrete classes
of that type, each one can have very different implementations. Design Patterns provide guidance
like Program to an interface (type) not an implementation (concrete class) which can result in
really good OO code.
When to use Inheritance, when to use Composition, when to use Parameterized Types? Is
delegation the right design decision in this context? There are various questions that comes to a
programmer’s mind when they are trying to design highly reusable and maintainable code.
Knowledge of design patterns can really come handy when making such decisions.
An object oriented program’s run-time structure often bares little resembles to this code structure.
Sometimes looking at the code does not give us the insights into run-time structure. Knowledge
of design patterns can make some of the hidden structure obvious.
We all know that lack of continuous refactoring and design that doesn’t take change into account
risks major redesign in the future. Over the years we’ve also learnt that big upfront designs can’t
standup against the constant change/additon of software requirements. We’ve leant grouping
elements with similar change life cycle together yields in far more flexible and extendable design.
If we think some behavior or element of behavior is most likely to change, we try to abstract that
behavior in one place. While we understand these concepts are important design patterns really
make it possible to design such systems. Each design pattern lets some aspect of the system
structure vary independently of other aspects, thereby making a system more robust to a
particular kind of change.
4.2 Design pattern could come to assistance & UML diagram and an implementation for
the pattern recommended
Singleton design pattern
Singleton pattern is one of the simplest design patterns in Java. This type of design pattern comes
under creational pattern as this pattern provides one of the best ways to create an object.
This pattern involves a single class which is responsible to create an object while making sure
that only single object gets created. This class provides a way to access its only object which can
be accessed directly without need to instantiate the object of the class.
(tutorialspoint, 2018)
Structure
Make the class of the single instance responsible for access and "initialization on first use". The single
instance is a private static attribute. The accessor function is a public static method.
(sourcemaking, 2018)
4.3 Suitable Design pattern for handling this requirement & specific UML class diagram
and Implement design
Adapter Pattern
This pattern is easy to understand as the real world is full of adapters. For example consider a
USB to Ethernet adapter. We need this when we have an Ethernet interface on one end and USB
on the other. Since they are incompatible with each other. we use an adapter that converts one to
other. This example is pretty analogous to Object Oriented Adapters. In design, adapters are used
when we have a class (Client) expecting some type of object and we have an object (Adaptee)
offering the same features but exposing a different interface.
To use an adapter:
1. The client makes a request to the adapter by calling a method on it using the target interface.
2. The adapter translates that request on the adaptee using the adaptee interface.
3. Client receive the results of the call and is unaware of adapter’s presence.
Definition:
The adapter pattern convert the interface of a class into another interface clients expect.
Adapter lets classes work together that couldn’t otherwise because of incompatible
interfaces.
Class Diagram:
The client sees only the target interface and not the adapter. The adapter implements the target interface.
Adapter delegates all requests to Adapter.
Here instead of having an adaptee object inside adapter (composition) to make use of its
functionality adapter inherits the adaptee.
Since multiple inheritance is not supported by many languages including java and is associated
with many problems we have not shown implementation using class adapter pattern.
Advantages:
Disadvantages:
(geeksforgeeks, 2018)
4.4 Design pattern enable to obtain the additional functionality required by the queue
Supplement your answer with a UML class diagram
Iterator Pattern
Iterator Pattern is a relatively simple and frequently used design pattern. There are a lot of data
structures/collections available in every language. Each collection must provide an iterator that lets it
iterate through its objects. However while doing so it should make sure that it does not expose its
implementation.
Suppose we are building an application that requires us to maintain a list of notifications. Eventually,
some part of your code will require to iterate over all notifications. If we implemented your collection of
notifications as array you would iterate over them as:
And if it were some other collection like set, tree etc. way of iterating would change slightly. Now, what
if we build an iterator that provides a generic way of iterating over a collection independent of its type.
Class Diagram:
Here we have a common interface Aggregate for client as it decouples it from the implementation of your
collection of objects. The Concrete Aggregate implements createIterator() that returns iterator for its
collection. Each Concrete Aggregate’s responsibility is to instantiate a ConcreteIterator that can iterate
over its collection of objects. The iterator interface provides a set of methods for traversing or modifying
the collection that is in addition to next()/hasNext() it can also provide functions for search, remove etc.
Let’s understand this through an example. Suppose we are creating a notification bar in our application
that displays all the notifications which are held in a notification collection. NotificationCollection
provides an iterator to iterate over its elements without exposing how it has implemented the collection
(array in this case) to the Client (NotificationBar).
(geeksforgeeks, 2018)
Bibliography