4.1 Design Patterns

This chapter will outline the design patterns used in the proposed system. The architect Christopher Alexander argued that design patterns provide common solutions for common problems in programming. In other word, for any problem occurring in our system several times, the core point is to provide an effective solution once rather than doing it several times.

Design patterns are categorized as behavioral, creational and structural. The design patterns used in this work are Model-View-Controller (cf. Section 4.1.1), the Factory Pattern (cf. Section 4.1.2), Strategy Pattern (cf. Section 4.1.3) and the Singleton Pattern (cf. Section 4.1.4).

4.1.1 Model-View-Controller

The Model-View-Controller (MVC) is typically used for developing user interfaces. The intent of this pattern is to separate the business logic and user view so that the application is hierarchical (Gamma 1998).

This pattern comprises three parts, the interaction between these parts is shown in Figure 4.1.1. The model elements mainly encapsulates the user data and business logic, the view element refers to the user interface while the controller manages the interaction between the model and the view. This pattern is very suitable for the web application development. Figure 4.1.2 illustrates the implementation of MVC pattern in this project. The primary advantage of this pattern is that it make the software more hierarchical with the separation of the various views. However, it may be unsuitable for small applications having adverse effects on the application’s performance and design.

Figure 4.1.1 (RegisFrey 2010)
Figure 4.1.2: The class diagram of MVC pattern