Design Patterns

Behavioural Design Patterns




  1. Iterator Pattern - has been used to get way to access the elements of a collection object in a sequential manner without any need to know its underlying representation. The android client implements a container class with all the patient’s records and an iterator will be used to access the elements of the collection.

  2. Mediator Pattern - has been used to reduce communication complexity between multiple objects and classes by providing a mediator class which normally handles all the communications between different classes. . A Chat class has been provided that assigns the doctor to the patient (as the user is required to manually type in their doctor’s name) The android client provides a ChatMessaging class to allow the communication between the patient and their doctor. (the mediator class)



  3. Interpreter Pattern - This pattern has been used by creating a Response.Listener interface which is used after a GET or POST request has been made to the server. It will get the response by the server in a JSONObject format and interpret the results.

  4. Strategy Pattern - has been used to enable an algorithm’s behaviour to be selected at runtime. For instance, depending on the username and password inputted on the home screen, the user will be able to access the application either from the patient’s or doctor’s point of view. Another example would be saving the data in the local database if an online connection to the database is not available.

Creational Design Patterns




  1. Builder Design Pattern - has been used to separate the construction of a complex object form from its representation so that the same construction process can create different representations. To implement the FatSecret API for the “SearchFood” class a different class “Food” was needed to create a different representation for each food returned in the JSON that contains the name of the food as well as its number of calories. The “SearchFood” class plays the part of the “director” class which invokes the “builder” (“Food” class) which creates a part of the object each time it is called and saves all the intermediate states.

  2. Singleton Pattern -ensures one class has one instance providing a global point access to it. This pattern have been used to coordinate actions across the system and to permit lazy allocation and initialization. For example Address, Location, Person, Patient and Visit are java classes that create new instance of the class if one does not exist. If an instance already exists, it will return an instance to that object.

Structural Design Patterns




  1. Design Pattern Adapter -has been used to work as a bridge between two incompatible interfaces by joining functionalities of idependent or incompatible interfaces. This pattern was used to implement the ActiveVisitesArray, LocationArray, PatientArray, PatientHierarchy, PatientVisitsArray, ScreenSlidePager, SettingsArray and VisitExpandableList adapters.

  2. Filter Pattern -has been used to enable the developer to filter a set of objects using different criteria and chaining them in a decoupled way through logical operations. The project has a Food singleton that has food name and calories as properties. The SearchFood class is used as a filter to return the objects depending on the required criteria.


  3. Composite Pattern - has been used to treat a group of objects in similar way as a single object. This pattern creates a class that contains a group of its own objects. The project provides a Food Class having a list of Food objects. The Food class will be further used to create and print any food searches.