Should I always use complex components?

When to use complex components?
When is it better to place form elements directly on a page?
What are the advantages of one vs the other?

  1. Complex components (CC) pros:
  • using one part of form (e.g. Address section) within few different forms or few times on the same form,
  • dividing work between many people (simultaneous artifact editing isn’t possible).

Example: you have address section and you want to use it on Form 1 (every field from section is needed) and Form 2 (you don’t need Country field). It’s better to use the same complex component twice (and set visibility condition on Country to adjust CC to both forms) than creating whole section again. However, you need to remember that every change in one CC has impact on all the forms that have this CC.

Example 2: you have few forms for a child benefit (500+, 300+ etc.) and you didn’t use CC. Now something has been changed in these processes and you need to edit children data fields. Because of lack of complex components you need to do the same change on every single form.

When it comes to dividing work, it’s not the most important benefit of CC but it’s useful sometimes. Many people can’t edit the same artifact (like form) in the same time but they can edit different complex components (and create form from them).

  1. Complex components cons:
  • transferring values between one complex component and the other needs using input mapping mechanism,
  • you can’t quickly find or change something in form source (ĹąrĂłdĹ‚o) if it is in complex component.

Example: you need to use someone’s pesel from personal data complex component (CC1) in summary component (CC2) in sentence using refrence - “Your pesel is $pesel”. At first, you need to create new variable in CC2 and use it (by editing CC2) and then input pesel from CC1 to CC2 (by editing form). If form doesn’t have complex components, you can just write your sentence and that’s it.

Example 2: you need to check where specific service has been used within one form. If you don’t have complex components you can just find name of the service in source (ctrl+f) but if you have multiple CC you need to check every CC and form what takes more time (and it’s possible you miss something).

Generally, the more complicated form is, the more difficult to use and edit complex components can be. For example, we have form for a child benefit (500+) which consists of complex components and also we have there components nesting (one complex component has another one etc.). That structure makes easy changes more difficult to do.


You can also combine these two solutions. We did it on another form for a child benefit (Rodzinny kapitał opiekuńczy) - some sections (like personal data) are directly on a page but some are CC, for example we have there 5 different pages with the same fields for spouse/parent data. Because there are pages we couldn’t use repeateable section so the best way was putting one complex component 5 times on that form - it saved time and it’s easier to maintain.

3 Likes

What should I consider if I wanted to choose the best strategy for a given project? What are key factors indicating I should use ComplexComponents or not?

You should consider:

  • complexity of the form - if form has a lot of services and fields that are dependent on other fields it’s better to place elements directly on a page.
  • universality of form elements - if some elements will be used within few forms in exact same state (or with slight differences) it’s better to use complex component.
1 Like