The program uses a piecewise linear approximation. The whole range of values ​​of the input variable is divided into 1, 2 or 3 sections, depending on external conditions. What English word to call the number of sites ? I want to adequately name the variable. Wikipedia did not help me.

Thank!

  • I propose to use a simple geometric word - Segments. - Kromster
  • Thanks, good idea! - drvlas

2 answers 2

Since "piecewise linear" in English sounds like "piecewise linear", your number is "number of pieces". Depending on the conventions for writing variables adopted in your language, this is written as numberofpieces , numberOfPieces , NumberOfPieces , number_of_pieces , number-of-pieces , etc.

  • Thanks for the option! However, I don’t like such a long name because will be used as an index, and there are large constructions. Something of 5-6 characters is very desirable. And taking NUMBER is somehow very impersonal. I thought there was a term that more clearly reflected what kind of number it is. Earlier I used the word SLICE, but it is clearly not the topic ... - drvlas
  • @drvlas: You shouldn't use quantity as an index. Because quantity is a quantity, not an index. If you need an index, use another variable, for example, “current piece index”. By the way, there is nothing wrong with long variable names. A long name is good, incomprehensible or worse than that ambiguous - bad. - VladD
  • Thank you, I agree on both points. But with the index - not our case. In the array of my variable descriptors, the index is the ENUM name, in this case, just SLICE (even earlier - SLICE_NUMBER, although PIECE_NUMBER is correct). So the applicability is tested by practice. And the name fights the perfectionist's eye ... Well, it looks like it will be like that :( - drvlas

If the name should be short, then the following approaches can be used:

  1. Common abbreviations. The common abbreviation for number is num.
  2. The abbreviation of words by removing all or some vowels. Pieces can be cut to pcs. In this case, this is particularly successful, since in English it is also a common abbreviation, even Google translator adequately translates "pcs".

Thus, depending on the standard adopted in your language, your variable can be designated by one of the following options:

num_pcs, numPcs, NumPcs, and so on.

With a strong desire to make it even shorter, you can shrink num to the letter 'n'. This is a less transparent option, and if it is important that the name is obvious, it is better not to use it. However, the designation of the number one by the first letter in programming is still common, and many programmers can guess without comment what the names n_pcs, nPcs and NPcs mean.

If you still need a variable for the index, then use something like cur_piece or cur_el (cur is a common abbreviation for current; el is a common abbreviation for element)

  • Thanks, I use both methods. I shorten my SLICE sometimes to Slc. Perhaps, I was let down only by the unwillingness to use PIECE as the basis for the name. But I see that I can not find a better one. That is, today my version will be this: PcsN (I still love the piece number, not the number o pieces). I accepted your answer, but I cannot add it, because my statue registration on the English forum has disappeared, and here I just registered. - drvlas