Which design pattern should I use?

Hi,

We need to add flexibility to our system and we are not sure of the approach we should choose to reach our goal. I’ll try to present the situation in the simplest way possible. If more info would be of any help, feel free to ask. Thanks in advance to take a look at my situation…

The actual platform
We have developed a web platform that works altogether with a mobile app. The mobile app is used by technicians to collect inspection and repair data and to send it to the database while the manager uses the web app to manage and produce reports.

The workflow is pretty simple :
1- Create a project (inspection or repair)
2- Add inspections or repair to be performed to the project
3- Sync the mobile device with the database so the technician can gather data about the projects - inspections or repairs that has been planned
4- Sync mobile app again with the database again to send back the information collected

The platform is focussed on one specific type of asset and it generates two types of report. So, actually, everything is mainly “static”. We designed forms with fields specifically for the type of asset we were concerned about. For example length, manufacturer, side, damage types, access methods… Reports are based on 2 templates (one for inspection data and the other for repair data) and there is no other possibility, the mobile app has also a static structure adapted to the specific asset and reproduces the structure found in the web app.

What we need to achieve
Clients seem to like the system model we developed but need a lot more flexibility. We have lately been asked to adapt our platform to a different asset type (which requires a set of information different from the the actual asset) and to be able to collect information using 50 different inspection templates already created in Microsoft Word. It means that :

  • The web app has to display information in 50 different ways depending of the type of inspection made for this new asset
  • The mobile app has to collect and send data for those 50 different templates
  • We need to generate 50 different reports, one per template.
  • Each step has instructions about how it has to be done
  • Some steps do use pictures to illustrate how to do it
  • Of course, it has to be as cheap as possible… :slight_smile:

Some stats from a sample of 5 reports :

  • total 51 inspection steps (items) to be performed by the technician
  • 19 items are unique and are repeated one to 4 times through the five reports
  • there is a total of 107 data fields
  • the 19 unique items contain 35 data fields
  • field types are : text fields, date fields, checkboxes and numeric fields

Extrapolated to the whole 50 reports (sample * 10) :

  • total 510 inspection steps (items) to be performed by the technician
  • 190 items are unique and are repeated one to 4 times through the five reports
  • there is a total of 1070 data fields
  • the 190 unique items contain 350 data fields
  • field types are : text fields, date fields, checkboxes and numeric fields

The client also asked to have the opportunity to add more and to modify the actual templates when needed.

The design…
Well I honestly don’t know a lot about design patterns and never really worried about them in the past. I read a bit about this aspect of programming but never really bothered about using them. Anyhow, this situation is kind of a wake up call… I would appreciate if some of you could help me determine what would be the best pattern(s) to apply in this situation. That would surely help me heading in the right direction.

We use Xojo for web development and Ionic framework for mobile (IOS and Android) since Xojo doesn’t create Android apps yet.

The scenario I imagine is as following :
1- The database would contain descriptive informations about every template such as id, name, field type, field name, control type, data type, number of each field type, picture reference, step support description…
2- These informations would be used to create the interface objects dynamically to hold the data both on the web app and the mobile device
3- Data would be stored and shared between Mobile and Database as JSON strings
4- Client’s Word templated will be filled with data from the JSON string for the specific inspection

I’ve been looking in the family of the Creational Design Patterns. It is hard for me to distinguish them from one another. It seems to me that the “Builder Pattern” would fit…

Is my approach correct in regard of the context?
Is the “Builder Pattern” the right choice?
Any suggestion about a better approach?

Thanks to those who at least took time to read that loooong post. I feel I’m asking a lot…

Roger

  1. Dont hard code anything, make it all dynamic, from the fields to the templates to the reports.
  2. Give the customer a tool to make their own layouts for their templates and reports, what data they want on them, where they want it etc.
  3. Sit back and chill

Or just http://www.fastfieldforms.com (random google result) :slight_smile: