0

My Question


What are the best practices for creating a customized report based on a user form input? Specifically, how do I create an easy to maintain system which takes user input which is collected in a form and generate multiple paragraphs that explains the results of analysis.

Background


I am working on a very large multiyear project with a startup (who is my client). My job is to program analysis and generate reports to users. The pipeline for data looks like this:

Users enter information into a form -> results are calculated based on user input -> reports are displayed to users that share analysis.

It is really important to my client that some of the analysis results are displayed in paragraphs in a non-formal user friendly tone. The challenge is that the form and analysis are quite complex and will only get more complex over time. An example of the type of template for the paragraphs looks something like this:

resultsParagraphText=`Hi ${userName}. We found that the best ice cream flavour for you is ${bestIceCreamFlavor}. These other flavors ${otherFlavors} might be good for you. Here are the reasons why you might enjoy these flavors: ${reasonsWhyGoodFlavors}.
However we would not recommend these other flavors ${badFlavors}. Here are the reasons you should avoid this bad flavors: ${reasonsWhyBadFlavors}.`

These results paragraphs, of which there of many, have several minor problems which combined are significant:

  • If there is a bug in the code, minor visual errors would be visible to end users (capitalization errors, missing/extra commas, and so on).
  • A lot of string comparisons (e.g. if answers.previousFlavors.includes("Vanilla")) are required to generate the results paragraphs. Minor errors in the forms (e.g. vanilla in the form is not capitalized so answers.previousFlavors.includes("Vanilla") returns false even when user enters vanilla.) can cause errors in the results paragraph.
  • Changes in different parts of the project (form, analysis) directly effect how the results paragraph is made. Bad types, differences in string values, null or undefined values not being caught directly have an impact on how the results paragraph is made.
  • There are many edge cases (e.g. What if the user has no other suitable good flavors for them? The the sentence These other flavors ${otherFlavors} might be good for you. needs to be excluded).
  • It is hard to write paragraphs that use templates and have a non-formal tone.
  • and so on.

I have charts and other types of ways to display results and have explained to the client the challenges of sharing the information in paragraph form.

What I am looking for


I need examples, how tos, best practices on how to build a maintainable system for generating customized paragraphs based on user input. I know how to solve each of the individual issues (as they are fairly simple) but in a large project this will become very hard to maintain.

Notes

  • I have no clue what tags to use for the post. Feel free to edit/add tags if you know more appropriate ones.
  • The project is planning to use machine learning in the future other parts of the project. If there is a ML/AI solution that is useful please tell me.
  • I am working primarily in JavaScript, Python, C, and R, but if there is a library or tool in any other language please tell me. Finding a solution is very important to me and I would be willing to learn a lot find a best solution.
  • To avoid this question being removed because I have rephrased it to avoid asking for personal opinion, instead asking for existing examples or how tos. I can also imagine that others might find a solution fairly useful. If you can edit it to make the question less subjective please do so.
  • If you have any questions or need clarification feel free to ask. Any help is appreciated.
AzJ
  • 199
  • 1
  • 11
  • Asking for examples or how-to guides could get this closed as a request for offsite resources. “Needs more focus” seems relevant as well. – Nathan Hughes May 26 '21 at 21:53
  • @NathanHughes I thought you could ask for references? Was there a change in acceptable answer guidelines? I included descriptions of the mini problems I had to make it more clear what I was looking for. I really am just looking for advice on building a maintainable system. I don't know how to be more focused than that given the nature of the problem. If you have specific advice on how I can narrow it down I would be happy to reedit. I really tried to make the question fit into the guidelines as much as possible. – AzJ May 26 '21 at 22:30

0 Answers0