Posts by Maniero • 444,682 points
6,921 posts
-
6
votes1
answer78
viewsA: Is there anything that compares the type of the object?
This is probably what you want: if(component1 instanceof IndexComponent) { dosomething(); } I put in the Github for future reference. Then the variable needs to have an object that is of the…
-
2
votes1
answer40
viewsA: What is the use of declaring a column as Char(0)?
It is to keep the existing column in the template without occupying real data space. Some applications may want to access a column that no longer makes sense to exist in DB or that it is not yet…
-
4
votes1
answer76
viewsA: Creation of objects in Javascript
There is a huge difference between the 3. When you create the object through the constructor it is called and it is that code that will create the object as it was written. You might want to learn…
-
3
votes1
answer78
viewsA: The program hangs when it arrives at the while
The biggest problem is that the c++ is already doing the increment in the variable, the ++ is an operator that causes side effect and changes the value of the variable, so the attribution of the…
-
3
votes5
answers412
viewsA: Save or not the commands used in Mysql
No need, but you can write to some file to use again if you want. One thing is not related to another. I wouldn’t exactly call code what you do directly in Mysql, it is, but in general they are…
-
5
votes2
answers197
viewsA: "List Comprehensions" is it worth it?
Python is a slow language and people work with it, so that concern is not so important. If the performance is so important it is a case of using another language. The mechanism itself is not…
-
3
votes1
answer95
viewsA: In Java, getter and abstract Setter is correct?
I’m afraid of that kind of inheritance, I just can’t say she’s wrong because I don’t have enough information. You may be right, but I could only say by understanding every detail. Programming,…
-
2
votes1
answer74
viewsA: What is the meaning of the word Soundness in the context of programming languages?
Since I am not very academic I will answer what is most necessary to understand, someone more connected to the theory may find that not exactly so, I will speak just to understand why most people do…
-
1
votes2
answers342
viewsA: Error exited, Segmentation fault in C
The biggest problem is that it is not allocating memory to the array called teste in the secondary function, then burst the memory. And of course, I released this memory and the other one allocated.…
-
2
votes1
answer73
viewsA: I can’t get the None result out of this code
Logic is very complicated and redundant. I would even change a little the way of responding to the user to simplify the code, but I don’t know if you can so I’ll keep it that way. The biggest reason…
-
1
votes1
answer54
viewsA: Can I run ASP.NET on Nginx without Kestrel?
Good question. That indicates no, but I’m not sure if you’re going to use Nginx in the traditional way. Only I searched and I couldn’t find anything to confirm that. What I can tell you for sure is…
-
4
votes2
answers49
viewsA: Doubts about usability - var e functions - Javascript
Generally speaking yours is simpler, so between the two, it’s what I would do because I prefer the Navalha de Ocam. I’m not seeing reasons to do it the first way. But I could take a more real…
-
3
votes1
answer279
views -
2
votes2
answers61
viewsA: Do generic Helper/Utility classes hurt the Single Responsibility Principle (SRP)?
If well done no, on the contrary, it is a way of separating a responsibility that should not be in a normal class and even more, if used in the right way, can become more DRY that for me is the most…
-
2
votes2
answers92
viewsA: Does pushing inside a for loop not increment a declared Let in its scope?
Because that site of for is exactly for initialization, it only runs once, it is not part of the loop itself, it is a preprocessing that occurs to start the loop. It’s almost as if he was declared…
-
4
votes1
answer110
viewsA: It is possible to access a port via TCP/UDP from a web application
Generally speaking, in real web application, running in a standard browser, there is no way to do it directly. It is possible to use certain devices such as Websockets that encapsulate TCP within…
-
4
votes1
answer60
viewsA: Parameter of a function
They are not the same thing, they are completely different things. Even if they had the same name, they would be different things. To understand more about this you should see What is the difference…
-
3
votes1
answer113
viewsA: How can I get a program shut down by typing an empty space (' ') into python
I do not know if I should do so, but if I want to insist I would have to do the two-step operations, treat it as text and if it is not that then treat it as a number, but the ideal would be to treat…
-
1
votes2
answers96
viewsA: How to call a method not defined in the abstract class, but in the class that inherits it
This code should not return Hello World!. You cannot call an unknown method, that is, you cannot call a method that does not exist in the class itself. Even if it were technically possible it makes…
-
4
votes2
answers106
viewsA: Equality comparison
The first form is the most correct for almost all cases. I would even ignore the second. It may seem useful, but it’s best to use a more explicit way when you need this semantics. The second way…
-
2
votes1
answer52
viewsA: How to select a random string from a list in C#?
You cannot create the variable in the crazy like this, you need to use the correct syntax to declare it, tell what kind of object you are creating with the type of data you will have inside it.…
-
5
votes1
answer81
viewsA: How do I print the name of an instance in Python?
Don’t do it and don’t do it. You want to print the variable name, and that you know to a certain extent what it is. What would be the advantage of printing the name of something that’s already in…
-
1
votes2
answers45
viewsA: Deleting files from a PHP directory
Can you guarantee that the name will always look like this? If so, just filter when you find the expected name in the file being considered. If you cannot guarantee this you may need to do some…
-
2
votes2
answers59
viewsA: "print()" does not display the elements of the inserted list
You are starting the list inside the loop, so every time you pass by the list is reset, only save the last entered element. quantidade = int(input("quantas notas você já tem = ")) notas = [] for c…
-
1
votes2
answers126
viewsA: Factorial calculation in an arithmetic progression
The logic is very complicated, let’s think about it a little bit. You have terms that start at 2 and evolve from 2 to 2. So in the loop let’s call this termo instead of i as called to give more…
-
0
votes3
answers325
viewsA: Occurrence of a digit on an integer using Python
The code that takes the next digit, the division, is conditional, so only if you enter the count does that happen It is not that it only occurs in large numbers, it occurs in all that there is a…
-
3
votes5
answers135
viewsA: Problems with arrays in a Python password generator
You don’t have to do something so complex. You don’t need a array with the base characters, you can use a string. The most intuitive count is going by the size of the individual characters. If I…
-
1
votes3
answers848
viewsA: Return divisible by number in an array
There’s a syntax error in the comparison, it doesn’t make any sense, it has things played anyway. Again, without messing with the way you’re doing because it’s a basic exercise and maintaining the…
-
2
votes4
answers876
viewsA: How to capitalize all words in an array using toUpper?
You must create a new array and return it, it’s doing almost right, only it’s not creating the array, You’re trying to do it on your own, it doesn’t make sense. using a function itself mounted the…
-
0
votes1
answer75
viewsA: How to store numbers in a vector to display it later in C?
One problem is that you’re not reading 20 but only 5. Okay, you might have done so just to make it easier. But it is easier to use a definition that can be changed everywhere with ease. It’s…
-
3
votes4
answers500
viewsA: Return array with numbers larger than the reported Javascript
You have to create a new array temporary to include items that meet the established condition. You cannot return an element only. So I was on the right track, but I had this problem. You keep adding…
-
2
votes1
answer45
viewsA: Syntax inside a struct that looks like a function
This is a constructor method. Don’t know what it is? Has answer about: What good is a builder?. So this code will be executed when creating an instantiated object from this structure. Péra, which…
-
5
votes2
answers92
viewsA: What would be the function of this array?
First I suggest changing the learning strategy. First you learn the concepts then you go to codes. We are seeing many people asking here using the same strategy as you and our observation is that it…
javascriptanswered Maniero 444,682 -
1
votes1
answer48
viewsA: Vector does not print correctly
The biggest problem is that you are not reading the amount of data you think you are. You are starting to read the data and storing at position 1 of the array, whereas the array starts at position…
-
1
votes2
answers62
viewsA: Volatile and optimization
volatile is not an optimization engine, and so when you used it nothing was optimized. When you use this keyword you’re saying that this information can be changed at any time without your strict…
-
3
votes2
answers239
viewsA: What is the difference between ", " and "+" in Python?
In fact the operator + in this context makes the concatenation of texts in a simple way, which means that it will generate another object that will contain the contents of the two objects used with…
-
2
votes1
answer1555
viewsA: Vertical line in the middle of the Visual Studio Code screen
Go to Preferences -> Text Editor -> Markers and Rulers and uncheck Show Column Ruler. Source.
visual-studio-codeanswered Maniero 444,682 -
1
votes1
answer57
viewsA: Inconsistent Accessibility: "Teacher" parameter type is less accessible than "Professor.Insert(Teacher)"
Probably need to do Model.Professor as public to use in a method public. It seems that not coding thinking about accessibility, the existing field should not be private? Just because it works…
-
1
votes1
answer376
viewsA: Shortcut to Console command.Writeline in C#, is there?
It makes no sense to have a shortcut in the language. Java doesn’t have it either, it could have it in an IDE and it depends on which one you’re using. If you are using Visual Studio you can invoke…
-
7
votes4
answers20874
viewsA: How to extract only numbers from a string?
For such cases there is no need to have complication, do with substring(): cpf.Substring(0, 3) + cpf.Substring(4, 3) + cpf.Substring(8, 3) + cpf.Substring(12, 2) Even better:…
-
1
votes2
answers1848
viewsA: Recognize enter key in C
Are you sure you need all this complication and inefficiency? Is it a requirement? The right way to do this is not so. Much of what this code does is even useless. Never use a code like this in real…
-
1
votes1
answer80
viewsA: Convert for to while
The main problem is that it is not zeroing the counter when going to do the second loop, as the variable was ditching 10 at the output of the first it will pick wrong positions of memory in the…
-
2
votes1
answer65
viewsA: How to implement java exception handling within a swtich-case?
No need to treat the exception, do not let it occur, exception should only occur if it is something exceptional, you can prevent it from occurring then do it: if (num1 < num2 || num2 == 0)…
-
10
votes1
answer85
viewsA: Why does x += y add the values in an iteration?
r += v does not sum values in an iteration. It is an expression that accumulates value. It does not matter where it was used. If you’re inside an interaction then the buildup is done inside. The…
-
4
votes1
answer107
viewsA: If everything in C# inherits from Object, why aren’t all types by reference?
Because they don’t need to be :) There are reasons for efficiency for some types to be by value. Inheritance is something a little misunderstood and the fact that Object and ValueType being classes…
-
2
votes1
answer40
viewsA: "super" and private variables
The code doesn’t make much sense, starting with this.a = a is doing nothing useful, is assigning a variable by itself. To do this you do not need a constructor. If you don’t have the constructor…
-
5
votes1
answer55
viewsA: Processing time and clock time
Clock time, often called Wall clock time because that’s what you can evaluate from time spent to perform a task by looking at the wall clock, that’s how long it takes to perform that observably. In…
-
7
votes1
answer61
viewsA: How does this code of turning the number into binary work?
This is called recursion. I think the bulk of the explanation is in What is a recursive method?. There is a repetition yes, only there is a control command that says to repeat, the repetition…
-
7
votes1
answer99
viewsA: What is the use of true or false?
A good part of the operations with an algorithm must perform is to make a decision. In addition to following the normal flow or deviating and doing data manipulations, that’s all you need to do. The…
-
4
votes1
answer38
viewsA: Why does Phpunit not consider early return in method in code Coverage?
Code coverage means testing all possibilities, all code paths, make all situations have been simulated. The ideal is 100%, but in practice this is difficult to obtain, and can complicate a lot. In…