Is a government design template redundant for a PHP form?

I have a page that, when accessed, displays a table of information related to the video:

  • Embed code
  • Title
  • Description
  • Current gallery
  • Thumbnail Image

This information is read-only when the page opens first.

There is a selection menu that has the following options:

  • Change Description
  • Create thumbnail (upload / replace)
  • Change embed code
  • Change Gallery
  • Delete video

When the user selects a parameter, the same initial data table is displayed, but the corresponding form input is displayed if necessary.

For example, if "Change Description" is selected, the page reload and description text are replaced by text input. If Create Thumbnail is selected, the input to download the file is displayed.

The idea is to display all the information together, but limit how much you can edit at a time.

I know that a state template is a possible solution, since each piece of data can be at least one of two states:

  • Display status
  • Form Input Status

But, my question is, will using a state template be redundant?

Currently, each time the page is accessed, each part of the form decides with the switch statement whether it should be in the "display" or "input" state, and then acts accordingly. I wonder if the implementation of the state template can change the form and create similar forms in the future.

Thanks!

+4
source share
2 answers

No, the state design pattern does not overflow. This is probably a very good algorithm for handling such a complex interface. I have used state engines in PHP several times; it helps you think creatively about the problem, and you often get a bonus in flexibility.

I want more programmers to know about such things.

+4
source

The more I use design patterns, including the state pattern in PHP, the more I am convinced that they save time. At first, this may take longer, but not much longer. However, when it comes to change and updating, they save a tremendous amount of time. Your code is better organized, clearer and less likely through a bomb to your code, which you get with tight binding outside the design templates. I made several PHP templates at php5dp.com, but nothing in dp state.

0
source

All Articles