3
Which is a good name
to define these types of inputs?
- chk_questao1
- rdo_questao2
- txt_questao5
- slc_questao3
Which nomenclature standard is best? Is there any such thing as good practice?
3
Which is a good name
to define these types of inputs?
Which nomenclature standard is best? Is there any such thing as good practice?
3
The current trend is not to use such prefixes. The reasons are several
<form>
, this means that a change in the screen will require a change in service. if
s to check the type of each field.With all this, I don’t want to say that you should never adopt some sort of standard with suffix and prefix, but that you should consider the impact of this.
Perhaps in your specific project, given the toolkit and the stack of the technologies you use, that makes sense. Overall, within the context of the technologies I know and the tools I use, I don’t think it does.
0
I usually use the first three characters to define the field type and then the rest for the field itself, for example: sel_uf, active chk_name, edt_name, edt_address... and so on.
Cool your interest in following patterns. This is very good to facilitate code maintenance.
Browser other questions tagged html
You are not signed in. Login or sign up in order to post.
On the server, do you need to know the type of element? In my opinion these "chk" only get in the way, you will have to write line by line instead of having a loop that goes from 1 to n, concatenating "questao+n". I use only the name of the same parameter,
questao
is fine. If it’s an array, just usequestoes[]
. Anyway, there’s no right answer, anything you read here will be based on opinions.– Renan Gomes
If, for example, in your database, the column is
str_questao_1
, in your html the field isslc_questao_1
, in his controller the variable ispst_slc_questao_1
, does not become a mess ? Leaves everything a name only, let the field name (select, textarea, input) follow the same column name in the database. The comrade’s answer above is good, for a collection, use array, but do not get prefixed.– William Novak