Skip to content

Design Patterns

Adailson Santos edited this page May 13, 2017 · 24 revisions

Design Patterns

Factory Method

Problem:

The problem consists of the fact that the tests for the clinical record classes required a clear and well defined way of instantiating both the clinical records appointment and the clinical records vaccination classes.

Solution Found:

Apply the factory method to define a specific creation method for each class.

Modeling:

Factory Method

GRASP Patterns:

Creator : the class responsible for the instantiation of the clinical records classes is one which was created solely for this purpose, thus being speciall chosen to do so.

Singleton

Problem:

The problem consists of the fact that current integration of the Data Access Object class causes multiple instances of connection to the database.

Solution Found:

Apply the singleton pattern in Data Access Object class. Because encourages use a global shared instance which prevents an object and resources used by this object from being deallocated.

Modeling:

Singleton

GRASP Patterns:

Indirection : the Data Access Object (or DAO) implemented in the TechVet application assigns the responsibility of mediation between the service classes and the database to an intermediate object (that is the data access object itself).

Creator : the class responsible for the instantiation of the DAO object has been chosen based on the necessities of the system (i.e. there must only be a single DAO instance at all times).

Decorator

Problem:

The clinic needs specific views for each user level. In future, the system will need more user levels. For now, there are two profiles:

  • Administrator (Can view the page user for creations)
  • Worker User (Can't view the page user)

Solution Found:

To resolve this problem, can be used the patterns decorator, in this way, if the clinic needs of a user level just add a class to implement the interface.

Modeling:

Decorator

GRASP Patterns:

Polymorphism : The same method is reused in the children class.

State

Problem:

There is a need of change the behavior of user according the state of the user. The administrator user can register, see the informations, delete, edit the clinic worker user.

Solution Found:

The solution for this, is to use the pattern state. Because it changes the behavior of a given object according to the state in which it is.

Modeling:

State

GRASP Patterns:

Template Method

Polymorphism

Problem:

It is necessary to find best practices for the registry of clinical consultation. For if other forms of procedure arise, the system will be ready to receive this.

Solution Found:

The solution found was to use the pattern template method, because it defines the order in which certain steps must be performed in solving a problem.

Modeling:

Template-method

GRASP Patterns:

Clone this wiki locally