803 1601900046139 Unit 40 Advanced Programming
803 1601900046139 Unit 40 Advanced Programming
Assignment title
LO3 Discuss the importance and dynamics of working within a team and the impact of team working
in different environments
Pass, Merit & Distinction P5 P6 M4 D3
Descripts
LO4 Examine the need for Continuing Professional Development (CPD) and its role within the
workplace and for higher level learning
Pass, Merit & Distinction P7 P8 M5 D4
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
Assessor Date
signature
Student Date
signature
Pearson Higher Nationals in
Computing
Unit 20 – Advance Programming
General Guidelines
1. A Cover page or title page – You should always attach a title page to your assignment. Use
previous page as your cover sheet and make sure all the details are accurately filled.
2. Attach this brief as the first section of your assignment.
3. All the assignments should be prepared using a word processing software.
4. All the assignments should be printed on A4 sized papers. Use single side printing.
5. Allow 1” for top, bottom , right margins and 1.25” for the left margin of each page.
1. The font size should be 12 point, and should be in the style of Time New Roman.
2. Use 1.5 line spacing. Left justify all paragraphs.
3. Ensure that all the headings are consistent in terms of the font size and font style.
4. Use footer function in the word processor to insert Your Name, Subject, Assignment No,
and Page Number on each page. This is useful if individual sheets become detached for any
reason.
5. Use word processing application spell check and grammar check function to help editing
your assignment.
Important Points:
1. It is strictly prohibited to use textboxes to add texts in the assignments, except for the
compulsory information. eg: Figures, tables of comparison etc. Adding text boxes in the body
except for the before mentioned compulsory information will result in rejection of your
work.
2. Carefully check the hand in date and the instructions given in the assignment. Late
submissions will not be accepted.
3. Ensure that you give yourself enough time to complete the assignment by the due date.
4. Excuses of any nature will not be accepted for failure to hand in the work on time.
5. You must take responsibility for managing your own time effectively.
6. 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.
7. Failure to achieve at least PASS criteria will result in a REFERRAL grade.
8. Non-submission of work without valid reasons will lead to an automatic RE FERRAL. You will
then be asked to complete an alternative assignment.
9. If you use other people’s work or ideas in your assignment, reference them properly using
HARVARD referencing system to avoid plagiarism. You have to provide both in-text citation
and a reference list.
10. If you are proven to be guilty of plagiarism or any academic misconduct, your grade could be
reduced to A REFERRAL or at worst you could be expelled 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]
Student’s Signature: Date:13/08/2021
(Provide E-mail ID) (Provide Submission Date)
Higher National Diploma in Business
Assignment Brief
Student Name /ID Number
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.
Unit Learning Outcomes:
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.
LO3. Implement code applying design patterns.
LO4 Investigate scenarios with respect to design patterns.
Assignment Brief and Guidance:
BOC Software solutions is leading software company in Kandy as system analyst you have to build
an application for Family Dental Care (FDC) considering given scenario.
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
Examine the Object oriented concepts given below. Provide diagrams and code snippets from
suitable specific programming language to supplement your explanations.
i) Class
ii) Object
iii) Message
iv) Encapsulation
v) Inheritance
vi) Polymorphism
vii) Aggregation/composition
Task 2
I) Design and build the detailed UML class diagram for the Family Dental Care system. Your
solution should demonstrate all inter-class relationships namely Association, Inheritance and
Aggregation/composition. The classes should include attributes and methods needed.
Draw the class diagram for the explained system. Including all notations and details and ensure
that the diagram has the required functionalities. Analyze the class diagram provided above and
derive code scenarios related to the UML diagram.
Task 3
I) Determine and briefly discuss the range of design patterns and describe at least one
design pattern from the three available types of design pattern. Provide suitable UML
diagrams for the given patterns.
II) Analyze the relationship between object-oriented paradigm and design patterns
providing a suitable example.
Task 4
Scenario 01
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 own 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.
You may include suitable attributes for the machine such as serial number, make, country
of origin and cost. Implementation should allow the user to enter details of the dental
scanner and create the sole instance of that machine.
Scenario 02
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. A complex treatment is a composition of several
elementary treatments possibly taking several visits by the patient, for example, a tooth
implant for a severely decayed tooth may require an antibiotic treatment for curing any
pus accumulation, an extraction of the affected tooth and finally a dental implant of a
Titanium tooth. The users of the system (mainly consultants and dentists) wish to handle
both of these treatments in a uniform way. For example, the message getDetails() sent to
an elementary treatment should provide details of a single procedure while the same
message given to a complex treatment would list details of each elementary treatment
that make up the complex treatment.
Scenario 03
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 enqueue 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.
For each of the above scenarios:
1. Select and Justify the most appropriate design pattern for each of the above given
scenarios.
2. Define and Draw class diagrams for above mentioned design patterns.
3. Develop code for the above scenarios using an appropriate programming language.
Critically evaluate why you selected the above design patterns and compare your
answer with the range of design patterns available? i.e. why you selected one and
not the others.
Grading Rubric
Class: A class is a user defined blueprint or prototype from which objects are created. It represents
the set of properties or methods that are common to all objects of one type. In general, class
declarations can include these components, in order:
Modifiers: A class can be public or has default access (Refer this for details).
Class name: The name should begin with a initial letter (capitalized by convention).
Superclass(if any): The name of the class’s parent (superclass), if any, preceded by the
keyword extends. A class can only extend (subclass) one parent.
Interfaces(if any): A comma-separated list of interfaces implemented by the class, if
any, preceded by the keyword implements. A class can implement more than one
interface.
Body: The class body surrounded by braces, { }.
Object: It is a basic unit of Object Oriented Programming and represents the real life entities. A
typical Java program creates many objects, which as you know, interact by invoking methods. An
object consists of:
State : It is represented by attributes of an object. It also reflects the properties of an object.
Behavior : It is represented by methods of an object. It also reflects the response of an object with
other objects.
Identity : It gives a unique name to an object and enables one object to interact with other objects.
Example of an object: dog
Message Passing: Objects communicate with one another by sending and receiving information to
each other. A message for an object is a request for execution of a procedure and therefore will
invoke a function in the receiving object that generates the desired results. Message passing
involves specifying the name of the object, the name of the function and the information to be sent.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and
Collections concepts with the Fundamentals of Java and Java Collections Course at a student-
friendly price and become industry ready.
Encapsulation: Encapsulation is defined as the wrapping up of data under a single unit. It is the
mechanism that binds together code and the data it manipulates. Another way to think about
encapsulation is, it is a protective shield that prevents the data from being accessed by the code
outside this shield.
Technically in encapsulation, the variables or data of a class is hidden from any other class and can
be accessed only through any member function of own class in which they are declared.
As in encapsulation, the data in a class is hidden from other classes, so it is also known as data-
hiding.
Encapsulation can be achieved by Declaring all the variables in the class as private and writing
public methods in the class to set and get the values of variables.
Inheritance: Inheritance is an important pillar of OOP(Object Oriented Programming). It is the
mechanism in java by which one class is allow to inherit the features(fields and methods) of
another class.
Important terminology:
Super Class: The class whose features are inherited is known as superclass(or a base class or a
parent class).
Sub Class: The class that inherits the other class is known as subclass(or a derived class, extended
class, or child class). The subclass can add its own fields and methods in addition to the superclass
fields and methods.
Reusability: Inheritance supports the concept of “reusability”, i.e. when we want to create a new
class and there is already a class that includes some of the code that we want, we can derive our
new class from the existing class. By doing this, we are reusing the fields and methods of the
existing class.
The keyword used for inheritance is extends.
Syntax:
class derived-class extends base-class
{
//methods and fields
}
polymorphism
The word polymorphism means having many forms. In simple words, we can define
polymorphism as the ability of a message to be displayed in more than one form.
Real life example of polymorphism: A person at the same time can have different characteristic.
Like a man at the same time is a father, a husband, an employee. So the same person posses
different behavior in different situations. This is called polymorphism.
then these functions are said to be overloaded. Functions can be overloaded by change in number
of arguments or/and change in type of arguments.
Method overriding, on the other hand, occurs when a derived class has a definition for one of the
member functions of the base class. That base function is said to be overridden.
Example:
Association is relation between two separate classes which establishes through their Objects.
Association can be one-to-one, one-to-many, many-to-one, many-to-many.
In Object-Oriented programming, an Object communicates to other Object to use functionality and
services provided by that object. Composition and Aggregation are the two forms of association.
n above example two separate classes Bank and Employee are associated through their Objects.
Bank can have many employees, So it is a one-to-many relationship.
Aggregation
Aggregation
Output:
Composition
Composition
Composition is a restricted form of Aggregation in which two entities are highly dependent
on each other.
Aggregation vs Composition
1. Dependency: Aggregation implies a relationship where the child can exist
independently of the parent. For example, Bank and Employee, delete the Bank
and the Employee still exist. whereas Composition implies a relationship where
the
child cannot exist independent of the parent. Example: Human and heart, heart
don’t exist separate to a Human
2. Type of Relationship: Aggregation relation is “has-a” and composition is
“part- of” relation.
3. Type of association: Composition is a strong Association whereas Aggregation
is a weak Association.
Task 4
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.
Decomposing System into Objects :
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.
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.
Designing for change :
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.
Structure
36
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.
[ CITATION sou181 \l 1033 ]
37
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.
4.4 Design pattern enable to obtain the additional functionality required by the queue
Supplement your answer with a UML class diagram
38
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.
39
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).
References