INFORMATION SYSTEM FOR FAMILY DENTAL CARE (FDC) FATHIMA HAFSHA ZIYARD ADVANCED PROGRAMMING REG. NO: COL/E-005674 BATCH: HND-COM-100 ESOFT METRO CAMPUS ESOFT METRO CAMPUS #3, De Fonseka Road, Colombo 04. Higher National Diploma in Computing & Systems Development / Business Management Assignment Submission Form Name FATHIMA HAFSHA ZIYARD ESOFT Reg. No COL/E-005674 Name of Group Members (If Applicable) Edexcel No Module Name Advanced Programming Name of the Lecturer Mr. Tharaka Date Due 24/07/2022 Date Submitted 24/07/2022 Fine Email-Address hafshaziyard99@gmail.com Contact No +94 77 155 7879 Check List () CD Assignment Brief Signature on Coversheet Formatting Sheet Harvard Referencing Signature on Student Declaration Herewith I agree for the given terms and conditions on plagiarism & Academic dishonesty also I declare the work submitted doesn’t breach these regulations. Note: Keep the softcopy of the assignment with you until the official results released by ESOFT. ESOFT has all rights to request the softcopy again at any time. hafshaziyard99@gmail.com __________________ Signature FATHIMA HAFSHA (COL/E-005674) 24/07/2022 _______________________ Date Advanced Programming 1 Higher Nationals Internal verification of assessment decisions – BTEC (RQF) INTERNAL VERIFICATION – ASSESSMENT DECISIONS Programme title HND in Computing - Application Dev / Software Eng. Pathway Assessor Mr. Tharaka Unit(s) Unit 20: Advanced Programming Assignment title Information System for Family Dental Care (FDC) Student’s name FATHIMA HAFSHA ZIYARD Internal Verifier Pass Merit Distinction INTERNAL VERIFIER CHECKLIST Do the assessment criteria awarded match those shown in the assignment brief? Is the Pass/Merit/Distinction grade awarded justified by the assessor’s comments on the student work? Has the work been assessed accurately? Is the feedback to the student: Give details: • Constructive? • Linked to relevant assessment criteria? • Identifying opportunities for improved performance? • Agreeing actions? Does the assessment decision need amending? Y/N Y/N Y/N Y/N Y/N Y/N Y/N Y/N Assessor signature Date Internal Verifier signature Date Programme Leader signature (if required) FATHIMA HAFSHA (COL/E-005674) Date Advanced Programming 1 completed Confirm action Remedial action taken Give details: Assessor signature Date Internal Verifier signature Date Programme Leader signature (if required) Date FATHIMA HAFSHA (COL/E-005674) Advanced Programming 2 Higher Nationals - Summative Assignment Feedback Form Student Name/ID Unit Title FATHIMA HAFSHA ZIYARD / COL-E 005674 Unit 20 – Advanced Programming Assignment Number 1 Assessor Submission Date Date Received 1st submission 24/07/2022 Mr. Tharaka Date Received 2nd submission Re-submission Date Assessor Feedback: LO1. Examine the key components related to the object orientated programming paradigm, analysing design pattern types. Pass, Merit & Distinction Descripts P1 M1 D1 M2 D2 M3 D3 LO2. Design a series of UML class diagrams Pass, Merit & Distinction Descripts P2 LO3. Implement code applying design patterns Pass, Merit & Distinction Descripts P3 LO4. Investigate scenarios with respect to design patterns Grade: Assessor Signature: Date: Resubmission Feedback: Grade: Assessor Signature: Date: Internal Verifier’s Comments: Signature & Date: * 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. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 3 Assignment Feedback Formative Feedback: Assessor to Student Action Plan Summative feedback Feedback: Student to Assessor My lecturer for the Advance Programming unit is Mr. Nuhman His lecturing style is perfect. He used a variety of interesting techniques to lecture us and supported us in completing our assignment on time. He not only encouraged us to do our best, but he also guided us to do our best. Assessor signature Date Student signature Date FATHIMA HAFSHA (COL/E-005674) Advanced Programming 4 Pearson Higher Nationals in Computing Unit 20 – Advance Programming FATHIMA HAFSHA (COL/E-005674) Advanced Programming 5 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. Word Processing Rules The font size should be 12 point, and should be in the style of Time New Roman. Use 1.5 line spacing. Left justify all paragraphs. Ensure that all the headings are consistent in terms of the font size and font style. Use footer function in the word processor to in sert Y ou r 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. 1. 2. 3. 4. 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 FATHIMA HAFSHA (COL/E-005674) Advanced Programming 6 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. 1. I know that plagiarism is a punishable offence because it constitutes theft. 2. I understand the plagiarism and copying policy of Edexcel UK. 3. I know what the consequences will be if I plagiarise or copy another’s work in any of the Assignments for this program. 4. I declare therefore that all work presented by me for every aspect of my program, will be my own, and where I have made use of another’s work, I will attribute the source in the correct way. 5. I acknowledge that the attachment of this document signed or not, constitutes a binding agreement between myself and Pearson, UK. 6. I understand that my assignment will not be considered as submitted if this document is not attached to the assignment. Student’s Signature: Date: hafshaziyard99@gmail.com (24/07/2022) FATHIMA HAFSHA (COL/E-005674) Advanced Programming 7 Higher National Diploma in Business Assignment Brief Student Name /ID Number FATHIMA HAFSHA ZIYARD / COL/E 005674 Unit Number and Title Unit 20 – Advance Programming Academic Year 2018/1 2021/22 Unit Tutor Mr. Tharaka Assignment Title Issue Date Submission Date 24/07/2022 IV Name & 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. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 8 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, analyzing 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. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 9 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. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 10 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. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 11 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. Emp Id Name Position Salary A001 Anton Director 1,000,000 LKR A002 Chamod Dentist 600,000 LKR A003 Supuni Dentist 600,000 LKR A004 Madhavi Dentist 600,000 LKR A005 Piyal Nurse 200,000 LKR A006 Kamal Nurse 200,000 LKR A007 Kapila Nurse 200,000 LKR 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). FATHIMA HAFSHA (COL/E-005674) Advanced Programming 12 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 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: 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. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 13 Grading Rubric Grading Criteria Achieved Feedback LO1 Examine the key components related to the object-orientated programming paradigm, analyzing design pattern types P1 Examine the characteristics of the object-orientated paradigm as well as the various class relationships. M1 Determine a design pattern from each of the creational, structural and behavioral pattern types. D1 Analyse the relationship between the object-orientated paradigm and design patterns. LO2 Design a series of UML class diagrams P2 Design and build class diagrams using a UML tool. M2 Define class diagrams for specific design patterns using a UML tool. D2 Analyse how class diagrams can be derived from a given code scenario using a UML tool. LO3 Implement code applying design patterns P3 Build an application derived from UML class diagrams. M3 Develop code that implements a design pattern for a given purpose. D3 Evaluate the use of design patterns for the given purpose specified in M3. LO4 Investigate scenarios with respect to design Patterns FATHIMA HAFSHA (COL/E-005674) Advanced Programming 14 P4 Discuss a range of design patterns with relevant examples of creational, structure and behavioral pattern types. M4 Reconcile the most appropriate design pattern from a range with a series of given scenarios. D4 Critically evaluate a range of design patterns against the range of given scenarios with justification of your choices. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 15 Acknowledgement First of all, I thank God for all the opportunities, trials and strength that have been showered on me to finish writing the assignment. I experienced so much during this process and this assignment also helped me in doing a lot of research and I came to know about so many new things. Not only from the academic aspect but also from the aspect of professionally. First and foremost, I would like to sincerely thank my lecturer Mr. Tharaka for the guidance, positive encouragement and warm spirit to finish this assignment. It has been a great pleasure and honor to have him as my lecturer. Secondly, my deepest gratitude goes to all of my family members. It would not be possible to write this assignment without support from them. I offer my special thanks to all my friends. May God shower the above-cited personalities with success and honor in their life. Yours sincerely, Fathima Hafsha Ziyard FATHIMA HAFSHA (COL/E-005674) Advanced Programming 16 Table of Contents Acknowledgement............................................................................................................. 16 List of Figure .................................................................................................................... 19 List of Table ..................................................................................................................... 21 Task 1 .............................................................................................................................. 22 Examine the Object oriented concepts given below. Provide diagrams and code snippets from suitable specific programming language to supplement your explanations. ............... 22 1.1 Object Oriented Programming (OOP) ................................................................... 22 1.1.1 Class ................................................................................................................. 24 1.1.2 Object ............................................................................................................... 27 1.1.3 Message............................................................................................................ 29 1.1.4 Encapsulation..................................................................................................... 30 1.1.5 Inheritance ........................................................................................................ 32 1.1.6 Polymorphism .................................................................................................... 33 1.1.7 Aggregation/composition..................................................................................... 35 1.2 Relationship between OOP and Design Patterns .................................................... 37 Task 2 .............................................................................................................................. 39 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. ..................................................................................................................................... 39 2.1 UML Class Diagram............................................................................................. 39 2.1.1 Association Relationship Evaluation ................................................................... 40 2.1.2 Inheritance Relationship Evaluation .................................................................... 40 2.1.3 Aggregation Relationship Evaluation .................................................................. 41 2.1.4 Composition Relationship Evaluation ................................................................. 42 Task 3 .............................................................................................................................. 43 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 .................................................................. 43 3.1 Design Patterns .................................................................................................... 43 3.1.1 Types of Design Patterns ................................................................................... 44 3.1.1.1 Creational Design Patterns .............................................................................. 44 3.1.1.2 Structural Design Patterns............................................................................... 44 FATHIMA HAFSHA (COL/E-005674) Advanced Programming 17 3.1.1.3 Behavioral Design Patterns ............................................................................. 45 Task 4 .............................................................................................................................. 53 Scenario 1 ..................................................................................................................... 53 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. 53 4.1.1 Dental Scan Machine ......................................................................................... 53 Scenario 02 ................................................................................................................... 56 Below table provides the hierarchy of the Employees and their monthly salary in FDC.56 Scenario 03 ................................................................................................................... 59 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 ............................................................. 59 Conclusion ........................................................................................................................ 61 Self-Criticism..................................................................................................................... 62 Gantt chart ....................................................................................................................... 63 References ....................................................................................................................... 64 FATHIMA HAFSHA (COL/E-005674) Advanced Programming 18 List of Figure Figure 1 Object Oriented Programming (OOP) .................................................................. 22 Figure 2 Class in our system.............................................................................................. 24 Figure 3 Class code for FDC system.................................................................................. 25 Figure 4 Object Denoted as Diagram ................................................................................. 27 Figure 5 Object Code Snippet ............................................................................................ 28 Figure 6 Message Passing Diagram.................................................................................... 29 Figure 7 Message Passing Code Snippet ............................................................................. 29 Figure 8 Encapsulation Diagram........................................................................................ 30 Figure 9 Implementing Encapsulation................................................................................. 31 Figure 10 Inheritance ........................................................................................................ 32 Figure 11 Inheritance Code Snippet ................................................................................... 32 Figure 12 Polymorphism .................................................................................................... 33 Figure 13 Polymorphism .................................................................................................... 33 Figure 14 overriding .......................................................................................................... 33 Figure 15 overloading ........................................................................................................ 34 Figure 16 Aggregation/composition .................................................................................... 35 Figure 17 Aggregation ....................................................................................................... 35 Figure 18 Relationship between OOP and Design Patterns - Example 01 ............................ 37 Figure 19 Relationship between OOP and Design Patterns - Example 02 ............................ 37 Figure 20 Relationship between OOP and Design Patterns - Example Output ...................... 38 Figure 21 UML Class Diagram.......................................................................................... 39 Figure 22 UML Association Relationship Evaluation .......................................................... 40 Figure 23 UML Association Inheritance Evaluation ............................................................ 40 Figure 24 UML Aggregation Relationship Evaluation ......................................................... 41 Figure 25 UML Composition Relationship Evaluation ........................................................ 42 Figure 26 Design Patterns ................................................................................................. 43 Figure 27 Singleton Class Diagram.................................................................................... 46 Figure 28 Composite Design Pattern Diagram.................................................................... 48 Figure 29 Treatment Types Implementation 01 .................................................................. 48 Figure 30 Treatment Types Implementation 02 .................................................................. 49 Figure 31 Treatment Types Implementation 03 .................................................................. 49 Figure 32 Treatment Types Implementation 04 .................................................................. 50 FATHIMA HAFSHA (COL/E-005674) Advanced Programming 19 Figure 33 Treatment Types Implementation Output............................................................ 50 Figure 34 Singleton Design Pattern Diagram...................................................................... 53 Figure 35 Singleton Applied .............................................................................................. 54 Figure 36 Scan Object ....................................................................................................... 55 Figure 37 Dental Scan Machine Implementation Output ..................................................... 55 Figure 38 Scanner Exists ................................................................................................... 55 Figure 39 Class for Employee............................................................................................ 56 Figure 40 Employees Types Implementation 01 ................................................................. 57 Figure 41 Employees Types Implementation Output .......................................................... 58 Figure 42 Employees Types Implementation 02 ................................................................. 58 Figure 43 Scanning List UML Diagram ............................................................................. 60 Figure 44 Gantt chart ........................................................................................................ 63 FATHIMA HAFSHA (COL/E-005674) Advanced Programming 20 List of Table Table 1 Hierarchy of the Employees and their monthly salary in FDC ................................. 56 FATHIMA HAFSHA (COL/E-005674) Advanced Programming 21 Task 1 Examine the Object oriented concepts given below. Provide diagrams and code snippets from suitable specific programming language to supplement your explanations. 1.1 Object Oriented Programming (OOP) Object Oriented Programming (OOP) is a programming approach that uses objects, logics, and functions to organize designs and data. When OOP ideas are used, huge systems may be broken down into smaller portions, making it easier for several programmers to work on the project. This is one of the reasons why many major corporations have adopted OOP. In the OOP idea, an object is a data field that has its own set of actions and properties. Objects that have been created in the system can be modified in numerous places within the software. Furthermore, these items are useful when creating larger and more sophisticated applications, making the system more user-friendly. When utilizing OOP, the first step for every programmer is to gather system requirements. The requirements will subsequently be translated into system objects and functions, which will be linked to needed system locations. This process is known as 'Data Modelling.' A 'Class' is used to name an object, and it specifies the object data types as well as program logic. 'Method,' which contains the object functions, will likewise be included in the class (howtodoinjava.com, 2022). Figure 1 Object Oriented Programming (OOP) FATHIMA HAFSHA (COL/E-005674) Advanced Programming 22 The majority of important software development nowadays is done with OOP. You're probably used to dividing down enormous issues into smaller ones and tackling them in discrete code units. You may also be familiar with functional programming, which considers code parts as exact mathematical functions that do not impact other elements, in other words, there are no side effects. When you get a handle on OOP, though, you'll find that it opens up a whole new world of problem-solving possibilities. Instead of creating a program, you construct classes with OOP. Data and functions are both contained in a class. You construct an object, which is an instance of that class when you wish to save something in memory. As an example, you may create a Customer class that contains customer-related data and methods. You must then build a new Customer class object if you want your software to generate a customer in memory. Object-oriented programming has several advantages over procedural programming: • OOP is faster and easier to execute • OOP provides a clear structure for the programs • OOP helps to keep the Java code DRY "Don't Repeat Yourself", and makes the code easier to maintain, modify and debug • OOP makes it possible to create full reusable applications with less code and shorter development time Benefits of Object-Oriented Programming Because of its adaptability, object-oriented programming is quite popular. In a programming environment, the ability to treat code structures as objects allows programmers to freely shape programs. Conclusion According to the text, OOPs are one of the most important subjects in programming languages. In order to do programming efficiently, a programmer needs have a thorough understanding of this notion. This article covers a wide range of topics, including the benefits and drawbacks of OOPs, as well as other key concepts. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 23 1.1.1 Class A Class in object-oriented programming is considered to be specific set of instructions, acting as a blueprint in order to create an object. Classes are also contemplated as real-life entities often. Classes define what an object will contain and how it will behave. Moreover, logic sequences included in any class are known as methods (w3schools.com, 2022). 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 an 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, { }. • Constructors are used for initializing new objects. Fields are variables that provides the state of the class and its objects, and methods are used to implement the behavior of the class and its objects. Figure 2 Class in our system According to the class diagram, modifier types are directly connected to encapsulation, which is an important aspect of Object Oriented Programming. Encapsulation, as a reminder, is a concept that connects data to the code that manipulates it. You can avoid misuse by restricting access. For example, ensuring that some variables can only be accessible through well-defined ways (the normal get/set combo of methods) ensures that we won't find any unexpected values or completely block outside access to specific variables/methods. There are three types of FATHIMA HAFSHA (COL/E-005674) Advanced Programming 24 access modifiers: public, private, as previously stated. When no modifier is supplied, Java offers default access control, which is comparable to protected. • public - the member can be accessed from anywhere • private - the member can only be accessed by other members within the same class This table only applies to class members, not whole classes. Only public or without a modifier may a non-nested class be. When a class is defined without a modifier, it can only be accessible by code inside the same package, however when it is declared public, it may be used in any package. The public class must be the file's sole (non-nested) class, and the file must be named after the class. Using visual code, a code snippet of a class written in Java is given below. The sample depicts the construction of a basic class called 'Room'. Figure 3 Class code for FDC system FATHIMA HAFSHA (COL/E-005674) Advanced Programming 25 According to the code snippet is located in the "Room.java" file. Because we'll make the class public so we can access it from another package, the name must match the class. The same is true for the following courses. Encapsulating a class is a typical procedure. This implies that we define member variables as private and modify them via public methods. For example, we want to allow someone to update the int ID field while simultaneously ensuring that int ID is always a positive integer. We may conduct a check and alter the field if the provided value passes our check using the public method. This is a set() function, and it's commonly used in conjunction with a get() method (because we can't read private members outside of our class) or when we want to control how and when a variable's value is read. Also worth noting is that protected is the least commonly utilized of all the access modifiers. If we want to, we can simply get around it. We may simply inherit the class whose protected members we wish to access from another package and then access them through that inherited class. With that in mind, protected is most typically used as a recommendation that states "This member is not supposed to be accessible by non-subclasses in a separate package," thus even if we can easily defeat protected access control, it's not recommended. Conclusion Modifiers are keywords that allow us to fine-tune how our class and its members are accessed, as well as their scope and behavior in specific scenarios. They give essential characteristics for our classes and members. To get the most out of them, every developer should become wellversed in them. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 26 1.1.2 Object An Object is known as a unique element, included with a series of properties and methods in order to implement a specific data type, which is also meaningful. Moreover, objects can be simply recognized as simple samplings of real-world entities in the system. An object can only be created if there is a class in the system (mozilla.org, 2022). • State: It is represented by the attributes of an object. It also reflects the properties of an object. • Behavior: It is represented by the methods of an object. It also reflects the response of an object to other objects. • Identity: It gives a unique name to an object and enables one object to interact with other objects. Eventually, the below diagram clarifies the structure of classes integrated with objects; Figure 4 Object Denoted as Diagram Below is a code excerpt for an object called employee, which has data like as employeeID, MOB, paydiscount, and finalamount. getPID, for example, would be one of the techniques (). Only Methods belonging to the payment class have access to the data associated with the class by default. By restricting access to its data, a class may assure that no other component of the program has interfered with it. It also means that the underlying data structures of an item may be concealed from other objects. If it is written properly, a class (and presumably a collection of other dependent classes – classes within classes that inherit the same traits and data) may be FATHIMA HAFSHA (COL/E-005674) Advanced Programming 27 re-coded and upgraded without affecting other areas of the program that need it. As long as the public-facing interface (API) and functionality stay the same, Figure 5 Object Code Snippet Conclusion The classes are as vital to Java programming as breathing is to our survival. In Java, it is the most fundamental unit of Object-oriented programming. A single variable or function cannot be created outside of a class. Everything in Java has to be contained within a class. The value of classes in Java may have been appreciated by the programmer. I also went through the syntax for constructing classes as well as objects from them. I also went through the examples and sample codes so you can simply put them into practice according to the scenario. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 28 1.1.3 Message When objects are included in a class, it is also essential to establish a connection between multiple objects. Eventually, objects will be sending and receiving messages, when two or more objects are communicating. While messages are passed, each object acts independently, as an instance of calling an object to change its display value (geeksforgeeks.org, 2022). Figure 6 Message Passing Diagram The method for acquiring access is depicted. A patient package object should receive a message from the class immunologist. The class immunologist creates the message, which is then forwarded to the package message handler, who checks it for authorization. If the message is authorized, it is transmitted to the employee message handler. The root class employee then authorizes delegation and delivery of the communication to the patient. Depending on the patient package, access may be permitted or refused. If access is granted, the patient sends the message to the target program element for further processing. Message passing is works only if there are two types of data’s like (int, string). If this function is in the employee class, we need to create an object. This is followed by a call to the function that brings up the data’s and pass the above function Below shown is a code snippet of a message, using Java language, on visual code. Figure 7 Message Passing Code Snippet FATHIMA HAFSHA (COL/E-005674) Advanced Programming 29 1.1.4 Encapsulation Encapsulation is an effective method to wrap multiple codes and their data manipulation together, under one specific element. The major reason for this concept is to protect certain data, without allowing an outside function to access them. For instance, variables in a class can be set as private, so that any function from outside the current class cannot access them (afteracademy.com, 2022). Encapsulation is: • • Figure 8 Encapsulation Diagram Binding the data with the code that manipulates it. It keeps the data and the code safe from external interference Similarly, same concept of encapsulation can be applied to code. Encapsulated code should have following characteristics: • Everyone knows how to access it. • Can be easily used regardless of implementation details. • There shouldn’t any side effects of the code, to the rest of the application. The idea of encapsulation is to keep classes separated and prevent them from having tightly coupled with each other. In this case, the treatment class has employed the Encapsulation approach. The treatment's details/variables have been generated using the private method, which implies that no other classes may directly access these characteristics. The public getter and setter methods were utilized to access these attributes of the Treatment class. If the treatment class has to be used elsewhere, for example, if the treatment details need to be used in the payment class, an object for the treatment class will be generated in that location, and these attributes will be accessible using the public getter and setter procedures. The properties, however, cannot be accessed directly. The information about the attributes has been hidden here, even though they can only be accessible directly by the treatment class, but it can be reached to the needed locations by utilizing the public getter and setter functions. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 30 Below shown is a code snippet of encapsulation, using Java language, on visual code. Figure 9 Implementing Encapsulation Conclusion I showed in the previous Java code how we can use getter and setter methods to achieve polymorphism; this way is actually rather versatile. If we want the variables to be read-only, for example, we may remove the setter methods. Similarly, in the example above, if you wish to make the variables write-only, you must remove the getter methods. The enclosed code is simple to debug and allows for unit testing. In our application, you may reuse the code and add new requirements. The implementation of the program definitions might be hidden. The user, for example, will never be able to see what variables are stored in the program. They'll interact with the program's getter and setter methods. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 31 1.1.5 Inheritance In object-oriented programming, inheritance is the mechanism of basing an object or class upon another object (prototype-based inheritance) or class (class-based inheritance), retaining a similar implementation. Also defined as deriving new classes (subclasses) from existing ones such as super class or base class and then forming them into a hierarchy of classes. In most class-based object-oriented languages, an object created through inheritance, a "child object", acquires all the properties and behaviors of the "parent object”, with the exception of constructors, destructors, and overloaded operators and friend functions of the base class (javatpoint.com, 2022). Figure 10 Inheritance Below shown is a code snippet of Inheritance, using Java language, on visual code Figure 11 Inheritance Code Snippet Conclusion Many of the advantages and disadvantages of class-based inheritance are well understood. Object-based inheritance has remained a little-known concept. Although it's been used in prototype-based programming for a long time, it's less commonly used in business modeling. We discover that object inheritance is quite effective in three cooperation patterns: actor—role, item—specific item, and composite transaction—line item, when we examine the notion in the context of business modeling. Object inheritance may be achieved in a class-based language like Java by identifying the specific characteristics of object inheritance that are helpful and carefully limiting its scope. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 32 1.1.6 Polymorphism Polymorphism is considered one of the important features of Object-Oriented Programming. Polymorphism allows us to perform a single action in different ways. In other words, polymorphism allows you to define one interface and have multiple implementations. The word “poly” means many and “morphs” means forms, so it means many forms (geeksforgeeks.org, 2022). Figure 12 Polymorphism Below shown is a code snippet of Polymorphism, using Java language, on visual code. Figure 13 Polymorphism Overriding is a feature that allows a subclass or child class to implement a method that is already offered by one of its super-classes or parent classes, for as employee. Figure 14 overriding FATHIMA HAFSHA (COL/E-005674) Advanced Programming 33 When a method in a subclass has the same name, same parameters or signature and same return type (or sub-type) as a method in its super-class, then the method in the subclass is said to override the method in the super-class. Figure 15 overloading Overloading allows different methods to have the same name, but different signatures where the signature can differ by the number of input parameters or type of input parameters or both. Overloading is related to compile-time (or static) polymorphism. Conclusion Polymorphism is a strong Java method that, when applied correctly, makes a class's design flexible and extendable, with a customizable implementation that is simple to construct. This is such a fundamental feature of Java that you can't even start without knowing what polymorphism is and how to use it in the language. This article attempted to provide a peek of certain complexities that may be useful in helping you code better in Java. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 34 1.1.7 Aggregation/composition The term "association" refers to a relationship that exists between two distinct classes that is established through their Objects. One-to-one, one-to-many, many-to-one, and many-to-many associations are all possible. An Object communicates with another object in Object-Oriented programming to leverage the capabilities and services offered by that object. The two types of association are composition and aggregation (geeksforgeeks.org, 2022). Figure 16 Aggregation/composition Code reuse is also best achieved by aggregation when there is no is-a relationship. Inheritance should be used only if the relationship is-a is maintained throughout the lifetime of the objects involved; otherwise, aggregation is the best choice Below shown is a code snippet of Aggregation, using Java language, on visual code Figure 17 Aggregation FATHIMA HAFSHA (COL/E-005674) Advanced Programming 35 When we constructed the room, we don’t want to include the doctor since if the doctor wants to connect with the rooms, we may add the manually. Is the strong connection. Not more than a connection of composition. Conclusion When a job demands OOP abilities, one of the most typical topics posed in interviews is "aggregation vs composition." You must follow the guidelines of UML diagrams if you are requested to conduct an object-oriented design. This allows people to comprehend your code's connections without needing to know your notation. UML may help you save a lot of time while designing a system. This class covers the fundamentals of certain advanced OOP topics, as well as visualizing the structure of an OOP design. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 36 1.2 Relationship between OOP and Design Patterns In order to get the most out of the components and properties, Object-Oriented Patterns are linked to design patterns. These notions, on the other hand, are typically linked in order to minimize programming complexity and increase code reuse. An example of how OOP and Design Patterns are combined is shown below. Figure 18 Relationship between OOP and Design Patterns - Example 01 When you look at the singleton design pattern cord above, you'll see that it was developed utilizing object-oriented programming methods since classes, constructors, and access modifiers were utilized properly to maintain encapsulation. The goal of employing this design pattern is to avoid the production of the same item several times. As a result, the constructor must be a public function according to the object-oriented programming style, but the design pattern changes it to a private function to prohibit object formation. Furthermore, the design pattern uses abstraction to make it easy for the developer or class users to utilize this class. Because if anyone needs to utilize this pattern, all they have to do is call the class function using the static method to obtain a class object. Figure 19 Relationship between OOP and Design Patterns - Example 02 FATHIMA HAFSHA (COL/E-005674) Advanced Programming 37 "Hello World!" is the code's output, as illustrated below. This indicates that the OOP components and design pattern have been effectively integrated. Figure 20 Relationship between OOP and Design Patterns - Example Output As a consequence, each object-oriented programming design pattern, such as classes, access modifiers, objects, and numerous components, produces efficient outcomes. Finally, this implies that design patterns and object-oriented programming principles have a close link. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 38 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. 2.1 UML Class Diagram Figure 21 UML Class Diagram The UML diagram depicts the properties, actions, and attributes of the information system's many classes. Furthermore, the graphic establishes particular links between various classes depending on their functions. Simply said, the system will be implemented totally based on the UML diagram for maximum efficiency. There are eight primary classes in the diagram, which include numerous connections such as Association, Inheritance, Aggregation, and Composition. The base functions of each class are used to examine these connections. All of the aforementioned classes are also linked to a suitable database for effective class record storage. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 39 2.1.1 Association Relationship Evaluation In order to meet FDC's needs, the system has a number of basic association links. A basic link between two classes is an association relationship. It means that some of the classes' characteristics or attributes have been shared in a specified way. An UML diagram was used to accurately depict the suitable system, which included all of the association connection classes. Furthermore, the fact that the majority of the system's classes are linked via association relationships is crucial. The learner, for example, has established a link between the 'Patient Registration' and 'Patient' courses. The association relationship is illustrated as a diagram in the UML example below. Figure 22 UML Association Relationship Evaluation 2.1.2 Inheritance Relationship Evaluation There are examples of inheritance connections in the system due to FDC's needs. Inheritance connections are simply built to allow a child class to inherit properties from a parent class. An UML diagram had been used to adequately depict the relevant system. The 'Employee' components of a class must be configured to be inherited at first. This is due to the fact that the dental system has four different types of doctors, all of whom have similar characteristics. However, there are times when some employees are required to have certain credentials and experience, but they are resolved as children classes. Dentist, Nurse, Manager, and Dental Consultant are four offspring classes inherited from the Employee parent class. The inheritance UML diagram sample is shown below, defining how the specific connection is depicted as an illustration. Figure 23 UML Association Inheritance Evaluation FATHIMA HAFSHA (COL/E-005674) Advanced Programming 40 2.1.3 Aggregation Relationship Evaluation The learner implemented the aggregate relationship between the classes 'Patient' and 'Employee.' This indicates that the existence of the Patient class is contingent on the presence of the Employee class. However, one of these classes might exist independently of the other, constituting the aggregation process. Figure 24 UML Aggregation Relationship Evaluation FATHIMA HAFSHA (COL/E-005674) Advanced Programming 41 2.1.4 Composition Relationship Evaluation The learner implemented that the classes, ‘Payment and ‘Appointment are in composition relationship. This means that the Payment class entirely depends on the Appointment class for existence. Taking a real-time scenario, a payment for a patient cannot be processed without the patient having an appointment, so the payment call is completely dependent. Figure 25 UML Composition Relationship Evaluation FATHIMA HAFSHA (COL/E-005674) Advanced Programming 42 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. 3.1 Design Patterns Design Patterns are a set of guidelines used by programmers to solve common difficulties during the development process. Object-oriented programmers are familiar with the idea of design patterns. During development, design patterns are mainly employed to solve frequent recurrent problems. A design pattern, for example, is like incomplete code that is used as a template to solve problems (sourcemaking.com, 2022). There are a number of elements that contribute to the formation of design patterns. Design patterns, for example, help to accelerate development by include proven and confirmed system elements. Most significantly, these patterns are reusable, which improves the system's quality and accuracy. These pattern templates assist developers in avoiding reoccurring issues caused by human mistake. In other words, if programmers become accustomed to designing patterns, they will be more comfortable with them and make less mistakes. In addition, there are three primary categories of design patterns. • Creational Patterns • Structural Patterns • Behavioral Patterns Figure 26 Design Patterns FATHIMA HAFSHA (COL/E-005674) Advanced Programming 43 3.1.1 Types of Design Patterns 3.1.1.1 Creational Design Patterns Creational patterns are specifically implemented for program object creation purposes, in order to develop quality and accurate objects. The major objective of these patterns is to reduce any complications while creating objects in a program. Moreover, the concept includes the factor of not considering object creation logics and declare them directly using operators (gofpatterns.com, 2022). 1. Factory Pattern Factory pattern method is used to create object templates for the program, using a ‘superclass’ which declares the main properties and behaviors, which can then be passed on to subclasses. The subclasses decide the specific class to be initiated from the parent classes. 2. Object Pool Pattern Object pool method is used to cache pools by sharing previous object pools, while creating new pools. Simply, all reusable objects can be stored as pools for later use. When a programmer needs to create a new object, the pool can be referred rather than creating from scratch. 3. Singleton Pattern Singleton pattern is used to make classes provide single occurrence objects on implementation and execution. For instance, the object class can be expressed as private and static method, which encapsulates the class data. 3.1.1.2 Structural Design Patterns Structural design patterns are implemented for a simple convenience, which is defining the relationship between multiple entities. The patterns are executed in a manner to simplify the task of providing relationships within a class entity. Various methods are included while considering structural patterns, listed as follows; 1. Adapter Pattern Adapter pattern method is implemented with major consideration of reusing code. The adapter pattern works as a connector to integrate multiple classes together. The major concept is that, during development, verified codes have a higher reliability, which motivates programmers to reuse verified codes throughout the develop process. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 44 2. Decorator Pattern Decorator design patterns are implemented for any additional interface design enhancements. The decorators will also be adding additional responsibilities, with developer requirements. Examples of decorators include sidebars or borders on the system interface. However, any decorator function will be static and its behavior cannot be changed after execution. 3. Composite Pattern Composite design patterns are used to define special ‘abstract’ classes. Abstract classes are used to represent certain inheritable functions, whereas composite patterns are also used for changing object behavior while parent functions are inherited in child class. The composite could also occur recursively and allows to deal with objects in a uniform manner. 3.1.1.3 Behavioral Design Patterns Behavioral design patterns are essential in identifying similar communications between multiple class objects. Programmers analyze these communications in order to identify specific patterns within the objects. Various methods are included while considering behavioral patterns, listed as follows; 1. Chain of Responsibility Pattern Chain of responsibility design patterns are used to handle object requests by wrapping elements using abstract functions. The chain establishes a connection between objects and allows communications. The sender object sends objects from the top of the chain, which travels through chain process and ends at the receiver. 2. Mediator Pattern Mediator design patterns are implemented to create reusable elements, using encapsulation methodology between interacting objects. The mediator analyses communication between objects and compare their object references, where the interaction passes through the mediator. The major objective is to partition objects in order to increase reusability. 3. Observer Pattern Observer design patterns are used to differentiate a dependent and independent functions. The dependent function will be known as ‘observer’, while the independent function acting as FATHIMA HAFSHA (COL/E-005674) Advanced Programming 45 abstract will be known as ‘subject’. So, when the properties of an independent function are changed, they are automatically altered in the dependent functions. Advantage of design pattern • They are reusable in multiple projects. • They provide the solutions that help to define the system architecture. • They capture the software engineering experiences. • They provide transparency to the design of an application. • They are well-proved and testified solutions since they have been built upon the knowledge and experience of expert software developers. • Design patterns don’t guarantee an absolute solution to a problem. They provide clarity to the system architecture and the possibility of building a better system Singleton Design Pattern According to The FDC's senior senirio, The Singleton Design Pattern is a Creational pattern in which just one instance of a class is created and only one global access point to that object is provided. Calendar is a frequent example of a class like this in Java, where you can't create an instance of it. It also has its own getInstance() method for obtaining the object that will be utilized. A class that follows the singleton design pattern will have the following features, Figure 27 Singleton Class Diagram FATHIMA HAFSHA (COL/E-005674) Advanced Programming 46 1. A private static variable, holding the only instance of the class. 2. A private constructor, so it cannot be instantiated anywhere else. 3. A public static method, to return the single instance of the class. Singleton design may be implemented in a variety of ways. I'll be going over the implementations of today's topic. 1. Eager Instantiation 2. Lazy Instantiation 3. Thread-safe Instantiation Conclusion The communication between classes and objects is the core of a behavioral design pattern. The command pattern's main goal is to encourage a larger degree of loose coupling between the parties involved (read: classes). Coupling is the process through which two (or more) classes interact with one another. When these classes interact, the ideal scenario is that they are not overly reliant on one another. That's referred to as loose coupling. So, a better notion of loose coupling would be interconnected classes that utilize each other the least. The necessity for this pattern developed when it was necessary to send requests without knowing what you were asking for or who the recipient was. The calling class is detached from the class that actually executes the action in this pattern. When the client asks it, the invoker class simply contains the callable method execute, which executes the required command. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 47 Composite pattern would be the appropriate design pattern to be implemented with the treatment type’s scenario, according to the requirements. Composite patterns are used in occasions where multiple objects are considered as a single object, which are initiated using tree structures. Figure 28 Composite Design Pattern Diagram Initially, the properties to be included in the class were assigned. Moreover, list method was used to store the sub treatments. The implemented code is shown below. Figure 29 Treatment Types Implementation 01 The sub treatments are stored as ‘Subsidiary’ which are treatments required by the hospital to carry out before the main treatment is done. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 48 Functions to add or remove patient sub treatments were also added, as shown below. Figure 30 Treatment Types Implementation 02 Following objects are used to return functions, whereas patient treatments are also defined. Three treatments are defined in the code, ‘Tooth Implant, Scaling and Cleaning and Antibiotic Treatment’ as treatment subsidiaries, to be done before the main treatment is done. Figure 31 Treatment Types Implementation 03 FATHIMA HAFSHA (COL/E-005674) Advanced Programming 49 The complete treatment type class code looks like. Figure 32 Treatment Types Implementation 04 The treatment type’s code output window is shown below. Figure 33 Treatment Types Implementation Output FATHIMA HAFSHA (COL/E-005674) Advanced Programming 50 Object-oriented paradigm Previously, structured programming techniques were used. Structured programming approaches were applied, which resulted in a host of problems. In structured programming, a top-down approach was adopted. To overcome these challenges, the object-oriented programming approach was created. In object-oriented programming, the bottom-up technique is utilized. It also keeps up with the increasing complexity of the world. An object-oriented program may be described as a set of data that restricts access to code. Object-oriented programming is a programming technique that involves the creation of a program using objects and a set of well-defined interfaces to those objects. Because it describes how components of a computer program must be constructed, the object-oriented programming approach is referred to as a paradigm. It also specifies how the various components should interact with one another (pcmag.com, 2022). Uses of Design Patterns Design patterns can help developers save time by providing tried-and-true development paradigms. Effective software design necessitates taking into account challenges that may not be apparent until later in the implementation process. For coders and architects acquainted with the patterns, reusing design patterns helps to eliminate minor flaws that can lead to large difficulties and improves code readability. People frequently only know how to apply specific software design strategies to specific challenges. These methods are challenging to apply to a larger set of issues. Design patterns are generic solutions that are described in a way that does not necessitate specifics connected to a specific situation. Patterns also help engineers to speak about software interactions using well-known, well-understood terms. Over time, common design patterns may be enhanced, making them more durable than haphazard designs (sourcemaking.com, 2022). FATHIMA HAFSHA (COL/E-005674) Advanced Programming 51 Analyze the relationship between object-oriented paradigm and design patterns In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design. A design pattern isn't a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. As Design Patterns are well documented and understood by software architects, designers and developers, then their application within a specific solution will likewise be well understood. Design Patterns give a software developer an array of tried and tested solutions to common problems, thus reducing the technical risk to the project by not having to employ a new and untested design. Design Patterns are well-known ways to resolving difficulties in OOP programming. Knowing design patterns might help you save time when deciding how to tackle a problem. Some design patterns, such as the Visitor Pattern, allow you to perform things that would otherwise be difficult or hard, such as adding new functionality to a collection of classes without their knowing about it. An interface or virtual methods that each class implements would be created using standard OOP procedures. This is in violation of the OOP open/closed paradigm. Patterns are used frequently in the Java as well as systems, so programmers apply them without ever learning them. The Decorator pattern is used by the majority of the classes in the Java IO namespace. Knowing this does not make someone an expert in OOP, but it can assist in making sense of things. Object-Oriented Programming (OOP) is a programming style or philosophy that divides code into objects and their connections. Design Patterns provide tried-and-true techniques of creating types/objects to tackle a certain problem in a software. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 52 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. 4.1.1 Dental Scan Machine Considering the application requirements of the dental scanning machine, singleton design pattern would be the appropriate pattern to be implemented. Singleton pattern is used to make classes provide single occurrence objects on implementation and execution. For instance, the object class can be expressed as private and static method, which encapsulates the class data. Figure 34 Singleton Design Pattern Diagram The singleton pattern has one of the simplest architectures of all the patterns. Because it is often necessary to give only one instance of our class, such as a single DB connection shared by numerous instances, implementing a separate DB connection for each item would be prohibitively costly. Similarly, instead of having several managers, an application that manages all problems should have a single configuration manager or error manager. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 53 Definition The singleton pattern is a design pattern that restricts a class's instantiation to to one object. Because the singleton pattern contains only one instance and more instances are restricted as the scenario requires, it is the most suited design for the scenario. Only one scanner is made, and the other scanner cannot be inserted at that time. The code snippet below should be used to create a new scanner, and if another scanner is added, a message stating "Scanner existing" should be displayed. The complete scanning machine class code is shown below. . Figure 35 Singleton Applied FATHIMA HAFSHA (COL/E-005674) Advanced Programming 54 The real results of the added data will be shown below, along with the run code with the object name scan. Figure 36 Scan Object Figure 37 Dental Scan Machine Implementation Output The output gets messages indicating "Scanner exists" until the scanner is transmitted for the second time, as shown in the figure below. Figure 38 Scanner Exists As a result, the singleton pattern used within the system performs as predicted by the scenario. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 55 Scenario 02 Below table provides the hierarchy of the Employees and their monthly salary in FDC. Table 1 Hierarchy of the Employees and their monthly salary in FDC Emp Id A001 A002 A003 A004 A005 A006 A007 Name Anton Chamod Supuni Madhavi Piyal Kamal Kapila Position Director Dentist Dentist Dentist Nurse Nurse Nurse Salary 1,000,000 LKR 600,000 LKR 600,000 LKR 600,000 LKR 200,000 LKR 200,000 LKR 200,000 LKR 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). Figure 39 Class for Employee FATHIMA HAFSHA (COL/E-005674) Advanced Programming 56 The complete Employee class code is shown below. Figure 40 Employees Types Implementation 01 FATHIMA HAFSHA (COL/E-005674) Advanced Programming 57 Figure 42 Employees Types Implementation 02 Figure 41 Employees Types Implementation Output FATHIMA HAFSHA (COL/E-005674) Advanced Programming 58 Scenario 03 Patients who need dental scans are kept in a First in First Out queue. Assume that yo u 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. The dental scans are retained in a First In First Out queue, according to the situation. Assume the learner has discovered an existing Queue container in a software library. Enqueue() and dequeue() are common queue procedures for adding and removing data, respectively (). Learners will, however, require some specialized operations such as search() to look for a specific patient and showAll() to display a list of all the patients in the queue. Such functions are not available in the library unit. So, for this demand, the iterator designing pattern is more appropriate since, according to the scenario, a library was provided with enqueue() and dequeue() functions for usage with the first in first out approach. However, according to the scenario, the serach() and view() methods should be displayed with those functions, therefore at this point, the learner has constructed an interface using the Iterator design pattern, which contains two functions: serach() and showAll (). The two functions in the class should be implemented by whoever implements the interface. The learner has constructed the patient object, which has some information that patients require. The enqueue() and dequeue() procedures will operate on the patient object in this case. The implementations and objects that are between the patient going to work in the PatientArea. People who utilize the PatientArea class can use functions like enqueue(), dequeue(), search(), and ShowAll(). In the Java and.Net programming environments, the Iterator design pattern is quite popular. This technique is used to gain a method to sequentially access the elements of a collection object without having to know its underlying form. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 59 Figure 43 Scanning List UML Diagram In the name, the learner has created an Iterator interface. The methods serach() and showAll are part of this interface (). PatientArea is a section for patients that has been expanded from the iterator interface. This class already contains the enqueue) (and dequeue() functions, and it must implement the Search() and ShowAll() operations, according to the preceding description (). Since it extends from the iterator's interface. After then, a complete patient library will be created. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 60 Conclusion Family Dental Care (FDC) designed an information system that focuses on the tasks and operations performed by personnel and consumers. FDC offers a wide range of dental procedures, therefore the system should be suitable for any situation. In the beginning of the assignment, basic Object-Oriented Programming (OOP) principles are presented with appropriate examples. The learner then began the first phase of system implementation by gathering the dental needs and information needed to finish the system. The student utilized DIA software to create a UML diagram from the requirements he had gathered. The example diagram contained relationships, inheritances, characteristics, properties, and actions. Eventually, the assignment established and explained the majority of the important class connections. The class relationships were used to create the information system. For more efficient development, specific design patterns were assigned throughout system construction. This same educator was able to grasp a variety of important programming ideas at a high level, which was beneficial for system development. The learner hopes that the existing method satisfies all of the standards for dental treatment and is successful enough to be used on a regular basis. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 61 Self-Criticism The learner gained valuable experience in designing and developing the information system for Family Dental Care (FDC). The student was able to pick up on a variety of sophisticated programming techniques. The student was also able to grasp more advanced ideas in objectoriented programming. The student hopes that the system representations would be helpful. The learner was able to discover some strengths throughout the design of the information system for Family Dental Care (FDC), such as. • Effective participation and interest in each system procedure are essential. • Analyze the prerequisites for an efficient dental care system. The student, on the other hand, was able to identify some of the flaws mentioned throughout the exercise, such as. • There is a lack of scheduled time allocation. • In some jobs, there is a lack of entire focus. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 62 Gantt chart Figure 44 Gantt chart FATHIMA HAFSHA (COL/E-005674) Advanced Programming 63 References howtodoinjava. 2022. object-oriented-programming. [ONLINE] Available at: https://howtodoinjava.com/java/oops/object-oriented-programming/. [Accessed 4 June 2022]. w3schools. 2022. java_classes. [ONLINE] Available at: https://www.w3schools.com/java/java_classes.asp. [Accessed 4 June 2022]. developer. 2022. Object. [ONLINE] Available at: https://developer.mozilla.org/enUS/docs/Web/JavaScript/Reference/Global_Objects/Object. [Accessed 4 June 2022]. geeksforgeeks. 2022. message-passing. [ONLINE] Available at: https://www.geeksforgeeks.org/message-passing-in-java/. [Accessed 4 June 2022]. afteracademy. 2022. encapsulation. [ONLINE] Available at: https://afteracademy.com/blog/what-is-data-encapsulation-and-de-encapsulation-innetworking. [Accessed 5 June 2022]. javatpoint. 2022. inheritance. [ONLINE] Available at: https://www.javatpoint.com/inheritance-in-java. [Accessed 5 June 2022]. geeksforgeeks. 2022. polymorphism. [ONLINE] Available at: https://www.geeksforgeeks.org/polymorphism-in-java/. [Accessed 5 June 2022]. geeksforgeeks. 2022. association-composition. [ONLINE] Available at: https://www.geeksforgeeks.org/association-composition-aggregation-java/. [Accessed 5 June 2022]. sourcemaking. 2022. design_patterns. [ONLINE] Available at: https://sourcemaking.com/design_patterns. [Accessed 15 June 2022]. gofpatterns. 2022. design-patterns. [ONLINE] Available at: https://www.gofpatterns.com/design-patterns/module2/three-types-design-patterns.php. [Accessed 15 June 2022]. educba. 2022. design-pattern. [ONLINE] Available at: https://www.educba.com/what-isdesign-pattern-in-java/. [Accessed 15 June 2022]. pcmag. 2022. object-oriented-programming. [ONLINE] Available at: https://www.pcmag.com/encyclopedia/term/object-oriented-programming. [Accessed 15 June 2022]. sourcemaking. 2022. design_patterns. [ONLINE] Available at: https://sourcemaking.com/design_patterns. [Accessed 15 June 2022]. FATHIMA HAFSHA (COL/E-005674) Advanced Programming 64