1164-1619624869751-40 - Advanced Programming - Reworded - 2021
1164-1619624869751-40 - Advanced Programming - Reworded - 2021
Mr. Tharaka
Assessor Internal Verifier
Unit 20 – Advance Programming
Unit(s)
Assignment title
S. Kevin Jeroshan
Student’s name
List which assessment criteria Pass Merit Distinction
the Assessor has awarded.
LO1. Examine the key components related to the object orientated programming paradigm,
* 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:10/08/2021
(Provide E-mail ID) (Provide Submission Date)
Higher National Diploma in Business
Assignment Brief
Student Name /ID Number S. Kevin Jeroshan
COL/E- 008889
Assignment Title
Issue 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 penalized 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
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
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 and analyze the
relationship between object-oriented paradigm and design patterns providing
a suitable example.
Task 4
Scenario 1
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
Below table provides the hierarchy of the Employees and their monthly salary in FDC.
All the Nurses are working under the Dentists and Chamod (Dentist) is working under the Supuni
(Dentist) and Madhavi (Dentist) is working under the Anton (Director).
Develop a system to display the details of all employees and your system should display which employee is
working under which employee clearly.
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 show All () to list all the patients in the queue. These additional
operations are not provided by the library unit.
For each of the above scenarios:
Select and Justify the most appropriate design pattern for each of the above given scenarios then Define
and Draw class diagrams for above mentioned design patterns and develop code for the above scenarios
(except for the 3rd Scenario) 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.
Grading Rubric
Grading Criteria Achieve d Feedback
First of all, I would like to thank my parents for their unrestrained contribution to study Higher
National Diploma (HND) in Esoft. And Esoft metro campus who gave us this valuable course from
Pearson UK. The last but not the least my Advanced Programming Lecturer Mr. Tharaka Sir for all
his support that he has given us from the HND session.
S. Kevin Jeroshan
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
Class
A class is a client-defined plan or model from which objects are created. It is concerned with the
organization of qualities or techniques that are common to all objects of the same type.
Constructors are used to introduce new items. Fields are factors that provide information on the
state of the class and its items, and methods are used to carry out the class's and its articles'
operations. There are several types of classes that are used in continuous applications, for example,
fixed classes, unknown classes, and lambda articulations.
A class should
Provide a well-defined interface - like the remote of the television.
Represent a transparent concept - like the concept of a television.
Be complete and well-documented - the television should have a plug and will have a
manual that documents all features.
The code should be robust - it shouldn't crash, just like the television.
Classes allow us how to represent complex structures within a programing language.
They need two components:
States - (or data) are the values that the thing has.
Methods - (or behavior) are the ways during which the thing can interact with its data,
A Java class can hold or many java methods. We use java classes in order to hold java
methods.
The following diagram is an example of a Loan Accounts. It describes a particular aspect
of the entire application.
Object
A Java object is a collection of information and methods that work their way through the
available information. An object has a state and a behavior.
The state of an item is saved in fields (factors), whereas strategies (capabilities) demonstrate
the behavior. Articles are created using forms known as classes.
An item is a state and behavior element, such as a seat, bicycle, marker, pen, table, car, and
so on. It might be physical or constant (substantial and immaterial). The financial framework
is an example of an immaterial object. An object has three characteristics;
Objects are often concrete (a real-world object, a file on a computer) or might be conceptual
(such as a database structure) each with its own individual identity.
One of the four critical OOP concepts is epitome. Legacy, polymorphism, and contemplation
are the other three. In Java, an epitome is a system that wraps information (factors) and code
that follows up on the information (techniques) into a single unit. In embodiment, the
components of a class are stored away from other classes and can only be accessed via the
procedures for their current class. As a result, it is also known as information concealment.
Benefits of Encapsulation
Figure 7: Encapsulation
Figure 8: Encapsulation Code
Inheritance is defined as the relationship in which one class obtains the attributes (techniques
and fields) of another. The data is made reasonable in a variety of tiered requests by the use of
legacy.
The class that gets the properties of another is known as the subclass (inferred class, kid
class), and the class that obtains the properties is known as the superclass (base class, parent
class).
Inheritance is the transfer of attributions and behaviors from the parent class to the child class.
Figure 10:
Inheritance
diagram
Figure 11: Inheritance code
Polymorphism
Polymorphism refers to an item's ability to take on many structures. The most well-known
application of polymorphism in OOP occurs when a parent class reference is used to refer to a
child class object. Polymorphism is defined as any Java object that can pass more than one IS-
A test. All Java objects are polymorphic in the sense that they will complete the IS-An
evaluation for their own type as well as the class Object.
Recognize that the only way to access to an article is via a reference variable. A reference
variable can only be of one type. The type of a reference variable cannot be altered while it is
spoken.
If the reference variable is not declared last, it might be reassigned to various articles. The
kind of reference variable determines the techniques that may be summoned on the article.
A reference variable can refer to any object of its declared kind or any subtype of its declared
kind. A reference variable can be declared as a type of class or interface.
Technique Overloading is the point at which a class has various strategies with a similar name,
however the number, types and request of boundaries and the return sort of the strategies are unique.
Java permits the client opportunity to utilize similar name for different capacities as long as it can
recognize them by the sort and number of boundaries
Dynamic Polymorphism
Dynamic Polymorphism in java is otherwise called Dynamic Binding or Dynamic Method Dispatch.
In this interaction, the call to an abrogated strategy is settled progressively at runtime instead of at
aggregate time. Runtime polymorphism is accomplished through Method Overriding.
Technique Overriding is done when a kid or a subclass has a strategy with a similar name,
boundaries and return type as the parent or the superclass, then, at that point that capacity abrogates
the capacity in the superclass. In less difficult terms, if the subclass gives its definition to a strategy
effectively present in the superclass, then, at that point that capacity in the base class is supp
regarding the strategy it abrogates, the superseding technique should observe adhering to compulsory
principles:
1. It should have a comparable technique name.
2. It should have an identical contention.
3. It should have an identical bring type back.
4. It should not have a more prohibitive access modifiers to be superseded.
Figure 13:
Polymorphism Code
Figure 14:
Polymorphism Code
Aggregation
Affiliation is a link between two distinct classes that develops via their Objects. Affiliation might be
one-to-many, one-to-many, or many-to-many. In Object-Oriented programming, an Object
communicates to another Object in order for that item's usefulness and administrations to be used.
The two forms of affiliation are structure and aggregation.
It has a connection. It's a one-sided romance. Both cases can live on their own.
Composition
One form of association is composition. Synthesis is defined as a connection in which one class
includes another class, and the contained class is dependent on the containing class in order to exist
independently.
We've already seen an illustration with a connection. We have a car item with a motor in that. This is
a representation of a layout. A motor cannot exist without a vehicle in this scenario. When compared
to Aggregation, the synthesis is more constrained. There isn't a Java inclusion in this work. It is
mostly regarded as a planning technique.
Composition is a restricted from of aggregation and it says two entities are highly depend on each
other.
1. In composition are both the entities are depend on each other.
2. When there is a composition between two entities, the component object cannot exsist
without the other object.
Figure 18: Composition Diagram
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.
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 and analyze the relationship between object-
oriented paradigm and design patterns providing a suitable example.
Design Patterns
The simplest methods used by experienced object-oriented software engineers are design patterns.
Design patterns are answers to common issues that software engineers confront while developing
software. These answers were discovered via trial and error by a number of software engineers
over a long period of time.
Design patterns can help to speed up the development process by providing tried and true
improved ideal models. Viable programming configuration necessitates taking into account
difficulties that may not become apparent until later in the execution. Reusing configuration
designs helps to avoid minor errors that might cause significant problems and improves code
readability for coders and draftsmen who are familiar with the examples.
Individuals frequently only perceive how to apply certain product plan methods to specific
challenges. These techniques are difficult to adapt to a broader range of situations.
Configuration designs are generic arrangements that are documented in a company that does not
require points of interest associated with a specific issue.
Engineers may also communicate using well-known, well-known names for programming
collaborations thanks to designs. After some time, ordinary plan examples can be improved,
making them more powerful than specifically designed plans.
Design patterns can be classified based on multiple criteria, the most common of which is the basic
underlying problem they solve. According to this criterion, design patterns can be classified into
various types, some of which are:
Creational Patterns
Structural Patterns
Behavioral Patterns
Creational design patterns are configuration designs that arrangement with object creation systems,
attempting to make objects in a way appropriate to the circumstance. The essential type of article
creation could bring about plan issues or added intricacy to the plan. Creational configuration
designs tackle this issue by some way or another controlling this article creation.
Creational Design Patterns address this issue by decoupling the client entirely from the particular
initialization process.
In this document, we'll discuss two types of Creational Design Pattern:
Singleton – Ensures that at most only one instance of an object exists throughout application.
Abstract Factory – Creates families of related dependent objects.
A singleton class is a class that has a solitary article and that novel item establishes a worldwide
office for all customers. For instance, consider a program with different classes that need to create
irregular numbers. It's anything but a smart thought to develop numerous free irregular number
generators. The arrangement of numbers that an arbitrary number generator makes are not really
irregular but rather the consequence of a deterministic computation. Thus, PC created irregular
numbers ought to truly be called pseudo-arbitrary numbers. In many calculations for creating a
succession of pseudo-arbitrary numbers, you start with a seed esteem and change it to get the
primary worth of the grouping. Then, at that point you apply the change again for the following
worth, etc.
The Singleton pattern involves one class which is responsible to make an object while ensuring that
only single object gets created. This class provides how to access its only object which may be
accessed directly without got to instantiate the thing of the category.
Structural Patterns
Structural patterns are worried about how classes and articles can be masterminded to shape bigger
constructions. Structural class patterns use legacy to form interfaces or various executions. For instance,
different legacy can be utilized to join highlights from at least two classes into a solitary class. This
permits at least two freely created class libraries to cooperate.
Structural object patterns determine an approach to make new items to acknowledge new usefulness. The
adaptability of item arrangement permits us to change the creation at run-time, which is inconceivable
with static class structure.
Structural design patterns are worried about how classes and items can be made, to shape bigger
structures. The underlying model examples works on the construction by recognizing the relationships.
These designs center around, how the classes acquire from one another and how they are formed from
different classes.
These patterns specialize in, how the classes inherit from one another and the way they're composed from
other classes. Structural patterns use inheritance to compose interface or implementations. Structural
object patterns describe ways to compose objects to understand new functionality
In this document, we'll discuss two sorts of Structural Design Pattern:
Adaptor – Adapting an interface into another consistent with client expectation.
Composite– Allowing clients to work on hierarchy of objects
Composite Design Pattern
Composite pattern is utilized where we need to treat a gathering of articles in comparative manner as a
solitary item. Composite example makes objects in term out of a tree construction to address part just as
entire progressive system. This sort of configuration design goes under underlying example as this
example makes a tree construction of gathering of articles.
This example makes a class that contains gathering of its own items. This class gives approaches to
adjust its gathering of same items. We are exhibiting utilization of composite example through after
model in which we will show representatives chain of command of an association.
As portrayed by Goff, "Create objects into tree construction to address part-entire chains of command.
Composite allows customer to treat singular items and syntheses of articles consistently".
When managing Tree-organized information, software engineers frequently need to separate between a
leaf-hub and a branch. This makes code more intricate, and accordingly, mistake inclined. The
arrangement is an interface that permits treating perplexing and crude items consistently. In object-
arranged programming, a composite is an item planned as a creation of at least one comparative articles,
all showing comparative usefulness. This is known as a "has-a" connection between objects.
Standards of conduct are worried about giving arrangements in regards to protest cooperation - how they
convey, how are some reliant upon others, and how to isolate them to be both reliant and free and give
both adaptability and testing capacities.
Behavioral patterns standards portray associations among items and spotlight on how articles speak with
one another. They can decrease complex stream diagrams to simple interconnections between objects of
different classes. Standards of conduct are additionally used to make the calculation that a class utilizes
just another boundary that is movable at runtime.
Standards of conduct are worried about calculations and the task of duties between objects. Standards of
conduct depict examples of items or classes as well as the examples of correspondence between them.
These examples describe complex control stream that is hard to follow at run-time. They shift your
concentrate away from the progression of control to allow you to focus simply in transit objects are
interconnected. Social class designs use legacy to disperse conduct between classes.
The Template Method is the less complex and more normal of the two. A layout strategy is a theoretical
meaning of a calculation. It characterizes the calculation bit by bit. Each progression summons either a
theoretical activity or a crude activity. A subclass fleshes out the calculation by characterizing the
theoretical activities. The other social class design is Interpreter design, which addresses a language as a
class pecking order and executes a mediator as a procedure on occurrences of these classes. In this
document, we'll discuss two sorts of Behavioral Design Pattern:
Iterator – allows you to traverse elements of a set without exposing its underlying representation.
Observer– allows you to define a subscription mechanism to notify multiple objects about any
events that happen to the thing they’re observing.
Observer Design Pattern
Observer pattern characterizes a one-to-numerous reliance between objects with the goal that when one
article changes express, every one of its wards are told and refreshed consequently. It is likewise
alluded to as the distribute buy in design. In onlooker design, there are numerous spectators (supporter
protests) that are noticing a specific subject (distributer object). Onlookers register themselves to a
subject to get a notice when there is a change made inside that subject.
A spectator item can enroll or unregister from subject anytime of time. It helps is making the items
protests approximately coupled. Observer pattern is used when there is one-to-many relationship
between objects such as if one object is modified, its dependent objects are to be notified automatically.
Observer pattern falls under behavioral pattern category Observer pattern defines a one-to-many
dependency between objects so that when one object changes state, all its dependents are notified and
updated automatically. It is also referred to as publish-subscribe pattern. Observers register themselves
to a subject to get a notification when there is a change made inside that subject.
Define a one-to-many dependency between objects so that when one object changes state, all its
dependents are notified and updated automatically. An abstraction has two aspects, one dependent on
the other encapsulating these aspects in separate objects let you vary and reuse them independently. A
change to one object requires changing others, and also when you don’t know how many objects have
to change. Observer pattern utilizes three entertainer classes. Subject, Observer and Client. Subject is an
item having strategies to append and segregate onlookers to a customer object. We have made a
theoretical class Observer and a substantial class Subject that is expanding class Observer.
Observer Pattern Demo, our demo class, will utilize Subject and substantial class object to show
eyewitness design in real life.
Figure 34: Observer Design Pattern Diagram
Object-Oriented Paradigm
Object-oriented programming (OOP is a programming worldview dependent on objects (having the two
information and techniques) that plans to consolidate the upsides of particularity and reusability. Items,
which are normally examples of classes, are utilized to cooperate with each other to plan applications
and PC programs.
The significant highlights of item arranged writing computer programs are −
1. Granular perspective in program plan.
2. Projects coordinated around objects, gathered in classes.
3. Zero in on information with techniques to work upon article's information.
4. Connection between objects through capacities.
5. Reusability of plan through making of new classes by adding highlights to existing class.