📜 ⬆️ ⬇️

How to design software to avoid problems: data processing web-form

When answering this question it is always necessary to ask yourself the question of software evolution. Which part of the system is most likely to change, and which is likely to remain constant?

We will consider this issue with examples. Consider several tasks that regularly occur in more or less large systems. The reasons for the emergence of this type of tasks are taken out of the scope of this post, but here we stop at the implementation.

Processing web form data


Forms are similar: added one field, removed another, cut down possible values ​​to numbers, made a multiple choice instead of a single one, etc. From the point of view of performance, a minor change. How much does the internal logic change?

')
The first thing that comes to mind when looking at simple forms is to match an object to a form, for each field of the form to provide the corresponding field of the object. When we receive a request, we write all the form fields into the appropriate fields of the object, validate, if there are errors, we give them to the user with fields binding and edit them, if everything is ok, we transfer them for further processing (how it will be processed - this already depends on the task ), if as a result of processing errors occurred - errors were drawn (possibly, together with the form).

We will develop the idea.

Let's look at the evolution of forms. As a rule, there are tendencies to (any combinations are possible):

From here, the following problems may occur:


What conclusions suggest themselves?


PS In the following topics we will consider the generation of reports, the analysis of the “raw” data of network protocols and other problems as desired by the habrasoobshchestva.

Source: https://habr.com/ru/post/116781/


All Articles