Skip to content

Design Overview

mnipper edited this page Oct 15, 2013 · 2 revisions

The system was designed to make it as easy as possible to add new question types, since this is the most likely thing to change. Much of the system design revolves around this.

###Design Patterns to Know

This app follows the MVC pattern, with activities serving as controllers and ActiveRecord models serving as data models. The views are a mix of XML in the res/layout directory and dynamically generated views in the QuestionFragments package.

A factory pattern (see QuestionFragmentFactory) is used to generate fragments that are dynamically switched out at runtime. These fragments are switched out in SurveyFragment in the question_container layout located in the fragment_survey layout XML file. The elements that all questions will have in common (the question text and navigation buttons) are placed in SurveyFragment. A question fragment for the given question type is generated by the QuestionFragmentFactory based on its question type in the database.

There are also hook methods in certain question types. This is done when a new question type inherits from an already existing question type and needs to hook in at distinct points to perform some operation. An example can be seen in SelectOneQuestionFragment and SelectOneQuestionWriteOtherFragment.

Clone this wiki locally