What are 'Magics' in Database and When to Use Them [closed] - database

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've seen a lot of article mentioning these 'Magics' like 'Magic Tables', 'Magic Columns', 'Magic Number', etc. What are they, really? Please give a concise explanation and example for these 'magics'.
[Edit]
The link below says that rownum is a magic column
http://www.oracle.com/technetwork/issue-archive/2006/06-sep/o56asktom-086197.html
Is it a general term?

I bet that the text is just using a metaphoric expression but there is a very similar term in programming called Magic Strings and Magic numbers. You can see in the wikipedia there are several meanings.
I personally think on the meaning of:
Unique values with unexplained meaning or multiple occurrences which
could (preferably) be replaced with named constants
This means that it is better to write:
for(int = 0; i < MAX_ATTEMPTS; i++){
Than
for(int = 0; i < 20; i++){
See this stackoverflow answer for more information why magic numbers/strings is an anti-pattern

Related

Removing Both Ends of a String in Google Sheets [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 months ago.
Improve this question
I have a Google Sheet which is constantly being populated via a Zapier zap. In one of the columns, I receive a PayPal "descriptor" which contains a unique identifier I need to do some look ups on other tabs within the same document.
Can someone point me in the direction of the correct REGEX to use to strip off the front and end of the string, for example:
Annual Fee-66421763-07142022191540
I would like to just have the piece in between the hyphens so the output reads simply:
66421763
Now, the front section will likely always read the same, the middle (the piece I want to extract) will be different and could change length too, as will the end section after the dash.
Any suggestions on how to achieve this would be great.
try:
=REGEXEXTRACT(A1; "-(\d+)-")

finding the biggest value [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
PLEASE NOTE: I am not looking for code, but for a way how to solve this problem.
My input is world that looks like this:
The problem is, i have to find the biggest number, without using OWN variables I could declare myself, and I'm only allowed to use turnLeft(), turnRight(), move(), isLeft/Right/FrontClear(), getNumber() and putNumber() functions to move < around the world.
Could you please give me a 'verbal solution' or a hint how to do such thing?
While you cannot use any variable, note that you do have available memory (getNumber() and putNumber()). For instance, you could think about leaving a mark in positions you have already been to implement some kind of flood fill.
Further, you can fill the floor with the biggest number you have seen yet. Basically, encoding your own state in the floor.
Important questions:
Is the configuration of the maze always fixed?
Is the range of possible numbers in the floor fixed to a reasonable range (e.g. digits 1-9)?

Dynamic string splitting to get the last word [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a challenge question like "What is your favorite movie?". There could be any question like this. I need last word of the question i.e. movie. without question mark.
Try this
String question = "What is your favorite movie";
String lastWord = question .substring(question .lastIndexOf(" ")+1);
When you select the element containing your challenge question, you can call .getText() (in Java; similar in other languages) to get the text inside. Then, you can use regular expressions or substring utilities in your language to strip out the last word.

Why is a numeric handle sometimes referred to as a "name"? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I've noticed in various C libraries, and most notably in the OpenGL API, that the word "name" is used to describe a simple integer value (often unsigned); example here. It sounds like what in other areas of development might be called an id (database keys) or a handle (file descriptors), which is why I'm surprised at the absence of these terms which I would ordinarily prefer over "name" since "name" conflicts with string identifiers or descriptions. I'm guessing the reasons to be historical.
Can anyone enlighten me with regard to the background of this term and whether or not it is still considered to be in vogue in the C community?
NB This is NOT a question about OpenGL so please could we keep the answers general - thanks.
Effectively the API you linked to is creating a structure in the memory space of the OpenGL implementation, and you are querying the fields of that struct using an enumeration to indicate which field. The documentation refers to this as 'symbolic name' which is what the equivalent token in the code to query of the struct in the program memory space would be:
x = texture.border_color becomes glGetTexParam(target, texture, GL_TEXTURE_BORDER_COLOR, &x)
so the enum parameter GL_TEXTURE_BORDER_COLOR is an equivalent to the name of the field's symbolic name border_color

different way to find a name to iterator [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
After writing so many for loop, I could not find to name iterator. I want write meaningful iterator' name, can you help me ?
ex ;
i
j
ii
jj
iii
jjj
usage :
for i = 0 ; i < ...
for j = 0 j < ...
Finding new iterator name makes my life a bit miserable. How do you find name to your iterator ?
If you have more then 3 nested loops in the same function, this is a code-smell.
You should probably refactor your code [move some staff into other functions, and use these functions].
i,j,k should be enough for most functions.
Try to have meaningful variable names, e.g. int RowNumber, int ColumnNumber.
loop indexes are not limited to 1 or 2 character names. try using a fully describing name, like current_element, inner_iterator, ...
the name should describe what you are indexing, but also tell the purpose of the loop.
I want write meaningful iterator' name
Then the name you use should reflect the meaning of what the iterator is used for.
For example if you are looping over products inside a loop of categories inside a loop of catgegory-groups, you might use names like producti, categoryi, groupi, perhaps together with number-of-item names likes productn/categoryn/groupn and/or array names like products/categories/groups.
I'd only use i for the simplest short non-nested loops that one can understand with a quick glance. Personally I wouldn't even use j; when loops are nested that usually calls for more self-explanatory variable names.

Resources