Posts by Maniero • 444,682 points
6,921 posts
-
12
votes1
answer1543
viewsA: What exactly is "Clean Architecture"? How and where to use?
The term was coined by Uncle Bob and the canonical information on this is in his page. It is a technique, which can have its effectiveness, to better explain something already existing, and of…
-
3
votes2
answers484
viewsA: How to use multiple answers for the same variable in just one if?
It is not possible, if you have two completely different conditions and distinct actions to be performed you will have to do them separately, it is a matter of logic and mathematics. No use using…
-
3
votes1
answer134
viewsA: How to perform mathematical operation within the MVC view
The ideal is not to do processing in view, then the correct solution is to create the model that already includes the calculated total value as a field of the model (may be a viewmodel if you do not…
-
1
votes1
answer86
viewsA: Problem for centralized printing in C
The formatting of printf() was made to work with many simple texts, in ASCII. In fact all basic C functions are for well-standardized tasks, when you get out of the minimum need C programmers use…
-
1
votes1
answer39
viewsA: Error in meter division
Because you started counting at 1, in general we always start at 0, this works best to access data in a array and to make counts like this. Starting from 0 and ending when it is equal to the number…
-
1
votes1
answer202
viewsA: How to declare an array variable as global in PHP securely?
You must communicate the data with the function. Functions receive and return values. That code makes no sense, but I’ll show you what I’d do if he did: function teste($a) { $a[] = "Ola"; $a[] =…
-
6
votes3
answers727
viewsA: Is it bad practice to store CPF and CNPJ in the same column of the database?
Search right here on the site what I and other people think about "good practices". Good practice is to do what is right for what you need. And only you with your concrete case can say what is right…
-
5
votes1
answer62
viewsA: What would be the 'right' way to declare variables in PHP OO?
var is considered obsolete and should no longer be used in new codes, it was a time that created the class but did not want to be another language, but then changed their mind and resolved that it…
-
4
votes3
answers303
viewsA: When I compare two strings to the "bigger" and "smaller" operators, what am I comparing?
You’re comparing the texts anyway. Each character is compared against each other in order that they meet to determine whether they are equal, greater or lesser. This is a loop used internally to…
-
10
votes3
answers1189
viewsA: Check if a string exists in an array
You need to look in array by content, can not buy a array with a potential element of it that will obviously give false, after all not even the type of the two data are equal, one is a list of data…
-
3
votes1
answer52
viewsA: "except" does not recognize value as wrong
You don’t want to use an exception there, you just want to check a state and make a decision, and to make decisions and divert the flow there is the command if. As the name says, an exception should…
-
5
votes2
answers379
viewsA: A simple question using % in JS
This is usually called the module operator, but actually it finds the rest of an entire division, people confuse that because it’s very similar (you can see more details of this in the mgibsonbr…
-
2
votes1
answer232
viewsA: How to limit decimal places in C#
You need to format the text to be used, can not use directly, so for two houses: $"{resultado:0.##}" But if you want to change the value and not just learn, which is not what the code does now, then…
-
3
votes2
answers347
viewsA: Doubt about the use of the Join method
The result isn’t exactly the same if you just take the join() just by to run and see that it is not. Your: var usuarios = [ { nome: "Diego", habilidades: ["Javascript", "ReactJS", "Redux"] }, {…
-
0
votes1
answer137
viewsA: How to get a program running in C without looping and compiling again?
Compiling has nothing to do with it. In fact that goto is very wrong and does not compile (I hope not Compile on some crazy compiler, if compile I would not use it anymore), it does not make any…
-
10
votes3
answers118
viewsA: Why doesn’t my program display the output values?
There are several problems with the code. Some don’t stop it from working, but that’s not how you make real code and you might be learning wrong if you keep doing it this way, so I’m going to show…
javascriptanswered Maniero 444,682 -
6
votes3
answers123
viewsA: Compare range of values
As the tracks are regular it is very easy because you can use only the math and a array with the values. I didn’t put all the values (without them I would fail in the tracks I didn’t put), but I can…
-
6
votes1
answer390
viewsA: What is the difference between Local Storage, Indexeddb and Websql?
Forget about Websql. It was supposed to be a relational database, but it was abandoned by the standard and today only works in browsers based on e=Chromium, without receiving attention, may even…
-
4
votes2
answers78
viewsA: Invert a string correctly
I don’t even think I need to manipulate the string, since it only asks to print reversed and not reverse the original, but I kept the change in the object because it may be that the statement may be…
-
8
votes2
answers89
viewsA: Problem with DRY
What you’re doing is walking both arrays at the same time, it is exactly the use case of the for. Using it would not only be repeating less but would also be leaving generic to any size that the…
-
7
votes1
answer191
viewsA: What is Borrow Checker?
What is Borrow Checker? It is the code parser contained in the compiler (it would not need to be but in Rust it is, part of the philosophy of language) that identifies whether the lifetime of…
-
3
votes1
answer115
viewsA: Creating a dictionary with void functions
Using the same method, if I understood it, is not possible because the method you wrote expects to work with a function that returns a string. In fact your dictionary only accepts functions with the…
-
9
votes1
answer130
viewsA: Functionality of ":" in C#
The : is used in several contexts and each one can have a difference of meaning. In this context it is an indicator of completion of a label. A label is a symbol marking any position in the code (or…
-
5
votes2
answers105
viewsA: How does an array of functions recognize the position of the next element?
It seems to me a matter of text interpretation. Read again the name of the mechanism. It is a pointer to function. So he’s a pointer, right? Every data can have its size obtained with the operator…
-
8
votes2
answers154
viewsA: Is there a rule for "type statements in class properties"?
Yes and no. If there is the Feature then you can use it. But don’t use where you don’t need it. Well, the question is much more complicated than this. Get into the PHP philosophy, or lack of. Yes,…
-
5
votes3
answers177
viewsA: How to initialize a constant with the value of time. Now() in Golang?
do Python projects where, when initializing the same I save a variable I highlighted the word variable. I can’t imagine why you tried to use a Go constant if in Python you used a variable, if you…
-
8
votes2
answers2392
viewsA: What is the meaning of the term "Hard Coded"?
What does the term Hard Coded mean? It means that information relevant to the functioning of the system has been placed in the code. In general we are talking about data, but in more specific cases…
-
3
votes1
answer117
viewsA: Bit-by-bit operations (XOR)
The xor It’s just a sum without the "go one": 101100100 -> 356 000000011 -> 3 --------- 101100111 -> 359 Whenever I find 0 and 0 is 0, whenever I find 0 and 1 or 1 and 0 is 1 and whenever I…
-
10
votes1
answer286
viewsA: What are Zero Cost Abstractions?
What are Zero Cost Abstractions? It is the ability to create an abstraction, to have a greater expressiveness than what you are doing, without incurring cost because of this. In general when you…
-
2
votes1
answer39
viewsA: Optimizing columns of Mysql tables that receive only two different values
In case I convert these char columns to tinyint, receiving the respective values 0 or 1, my queries will become more optimized? As darlings will not be more optimized because, in general, the type…
-
1
votes1
answer212
viewsA: How to write a string variable without breaking the line?
The fgets() picks up the ENTER you typed and that’s what’s breaking the line. Then in each variable you have to put a terminator in place of this character, one of them: name1[strcspn(name1, "\n")]…
-
2
votes1
answer68
viewsA: Logic of function loop
You did table test? And in the test you gave the result you think should happen? If you think that’s so, you could have justified how you got your result. I can’t even imagine why I would give what…
-
6
votes2
answers1334
viewsA: SQL decimal field size
It may depend on the database you are using (originally you did not have this information in the question). This is a numeric type that allows decimal places with accuracy, so it can be used for…
-
6
votes2
answers99
viewsA: Javascript . NET Zip() method
It doesn’t have ready anyway, but in the background it is only to map, what many already do. It seems to me that something like this solves most cases, but these algorithms can be complicated in…
-
2
votes1
answer73
viewsA: How to call the constructor within a method
Apparently that’s what you want: void Vetor::clear_vet() { contador = 0; for (int i = 0; i < 10; i++) vet[i] = 0; } I put in the Github for future reference. Eventually, just to make the code…
-
4
votes1
answer86
viewsA: Is it correct to use a static method of an abstract class?
The concept depends on the class, so you can only tell with a concrete case. The example just wanted to demonstrate, but precisely because it is artificial it prevents to give a definitive answer.…
-
3
votes2
answers61
viewsA: Error when assigning native function context
document.querySelector.bind() returns a HTMLElement in accordance with documentation. There are at least two methods querySelectorAll() available, what manipulates a document and what manipulates an…
javascriptanswered Maniero 444,682 -
10
votes2
answers138
viewsA: What is the Enumerable Zip in . NET?
The confusion with compaction comes from the fact that some compression mechanisms use the term to say they squeeze something, which is still a function of zipper since it adjusts something loose to…
-
5
votes1
answer198
viewsA: How to create multi-line strings in C++
You can use the symbol already used to escape special characters to indicate that the text continues on the next line. #include <iostream> using namespace std; int main() { cout << "isto…
-
17
votes3
answers1553
viewsA: Return the index of the largest element in an array
After many comments, the problem was up to another. As the question had repercussion I will try to give an answer that is what you need. Need to synchronize the index that is along with the highest…
-
6
votes2
answers240
viewsA: Github large files get corrupted
Git was not created to be used to manipulate large files. This is always at the disadvantage of it when it compares with other version control software. It doesn’t mean it doesn’t work, but it’s not…
-
4
votes2
answers180
viewsA: Exchanging last letter of a word using the 'replace() method
If you have to use this function the only way is to use a Regex to determine a pattern that does what you want. You can’t pass the position and you can’t just pass which character will be changed…
javascriptanswered Maniero 444,682 -
4
votes2
answers102
viewsA: Do partial imports bring advantages to the application?
For the application itself does not bring advantages, especially performance, but for the readability of your code depends, you may consider that it has yes or no advantage. When it matters only…
-
7
votes2
answers409
viewsA: Python algorithm complexity with two loops
The intern will not travel in n * n, nowhere shows it and it’s an inference from you that does it. Since that information doesn’t exist in the code, you should tell us why you found it. If it has…
-
6
votes1
answer75
viewsA: Variable loses value inside "for"
No, the variable a within the loop is not worth 2. Although the syntax is not so explicit, the loop used is creating an assignment, so at each step the value of a changes, including the first time.…
-
8
votes2
answers88
viewsA: When compiling the code, both numero1 and numero2 display the same value even having an increment
It is called preincrement so it takes the value of the variable in which it operates and changes its value by adding 1 to what already existed. And since the operator results in an expression the…
-
6
votes1
answer187
viewsA: Create more specific or more generic custom exceptions?
There’s no definitive answer to that. I know people always want a universal magic rule, but only the problem, the context, the environment being developed can determine what is most appropriate.…
-
3
votes2
answers57
viewsA: Reference is making a variable change the value of another
There’s no problem there, it’s happening what the code says to do, if that’s not what you want to do. You take an object referenced in a variable called Parametros and it says that you want that…
-
3
votes1
answer92
viewsA: Why are certain domains easier to model than others?
I think the answer lies in the question. Because they are already abstractions. And the programmer can do as he thinks best. At least who created the initial model can. Abstract mechanisms or models…
-
5
votes1
answer107
viewsA: Divisions miscalculating in C
I see no need for this kind of data to be double, but I will consider that it is a senseless requirement of exercise (actually can give slight difference, if need of accuracy neither of these two…