📜 ⬆️ ⬇️

Habits useful to every web programmer

Over time, web programmers develop habits that enter into the work process at the reflex level. Take at least the data from the form - each sensible programmer, as soon as he meets them, he immediately processes them for correctness. Sometimes even he does not notice.

I want to pay attention to several techniques that, to my regret, are not yet common habits. I really want to be banal and inappropriate.

The number of items on one page

Split the list into pages? What will the second page look like for a list of 101 items if your magic number is 100?


Get in the habit of using two magic numbers. For example, the numbers 100 and 120. Is the size of the list less than 120? - display all on one page. Is the list larger? - we display the first hundred on the first page, the rest (and there are at least 20) on the second.

')
Algorithms invent yourself.

List of pages for paginated output

Make it a habit to panic fear the following result:


But, instead of a trot point, page 4 could stand, but this was not foreseen out of habit. Fear and avoid. There are many ways, for example, my favorite.

Output null values

The fields in the database may be empty - post headers, product prices, message texts, and others - even if project managers assure you otherwise.

Let the phrases in the documentation, “the price field necessarily matter,” do not confuse you. Always check the field and otherwise output the word "empty." Next is the concern of the managers to rename this word. Perhaps they will still replace the "empty" empty space, but it will be a deliberate step.


List heading and list are not displayed separately.

A common mistake to write the headline "news" and only then process the list of news. The result of processing may be the phrase "no news" (and in the case of ignoring the previous habit - an empty space).


Get used to include the output of the header in the processing-output of the list itself. (In the example in the picture, the “news” header is the place to be inside the included file.)

Consider the grammatical features of languages

It is not necessary to set rigid constructions by type:
print $ phrase + $ value

It is possible that the human language in this place will want to swap the phrase and meaning. And even put the value in the middle:
$ start of phrase + $ value + $ end of phrase

I’m not even talking about processing endings: “5 habit has been published,” “25 May is written.”

* * *

But the most important habit that you need to start yourself was not told in this article, but in comments to it:
The main thing to remember is that you create a product for people, not for robots ... The more human your interface is, the more pleasure it will be to use it.

said zenden2k
And I completely agree with him.

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


All Articles