Posts by Maniero • 444,682 points
6,921 posts
-
76
votes2
answers4577
viewsA: DRY is to avoid redundancies, right?
Redundancy X Don’t Repeat Yourself This is repetition: valorDoProdutoComprado = valorDoProdutoComprado + 1 In many languages it could be so: valorDoProdutoComprado++ That’s dry? This:…
-
4
votes1
answer2244
viewsA: How to check if there is a null attribute in the object?
As I said in my comments, if you need all the data to have some value, the ideal is for the guy to guarantee it for himself. Can be via constructor and methods Setter (validating or being absent) in…
-
4
votes3
answers1360
viewsA: Faster way to access properties in a C#list
In this case, for each property a search is made in the list by the object at position i? Search is not exactly the word, I think it implies a long processing. A direct access to the element is made…
-
2
votes1
answer63
viewsA: What is the best way to use different logical operators in the same condition?
Operators have equal precedence in mathematics, and the operator && which is a AND takes precedence over the operator || which is a OR. Both have left-to-right associativity, so when the…
-
6
votes2
answers1190
viewsA: The Operator != is Undefined for the argument type(s)
If you need to check if the object is null, just check it, if you need to check the result, then the check should be another, depends on the return of the method used: public void salvar(Usuario…
-
6
votes3
answers218
viewsA: Possibility to create 200 columns in a database
You can do this but hardly anyone would do it in their right mind. Roughly speaking, the right thing would be: CREATE TABLE Resultado ( ID int PRIMARY KEY, Usuario int, Questao int, Resposta int, );…
-
3
votes1
answer690
viewsA: Temporarily store data in ASP.NET MVC
Obviously it has several solutions and without knowing each detail I would not know to state which the best. If you just need to be in the current application you can use the HttpContext.Application…
-
1
votes1
answer69
viewsA: How to pass the class (Teste2 teste2) as reference in the ("super") C++ constructor?
The code has several small problems, I don’t even know what to say to clarify the question because I didn’t understand it, I don’t even know if you have a specific question. There was a code played…
-
1
votes1
answer1048
viewsA: Encapsulation and Get and Set methods
The question was edited, I made based on the original code posted The exercise already seems to be well defined. So it is even difficult to say what is right. Without more accurate information you…
-
5
votes1
answer1335
viewsA: java.lang.Nullpointerexception: Attempt to invoke virtual method
Possibly this solves the specific problem (there may still be others): public class Principal extends AppCompatActivity { private Button btn; private EditText texto; BancodeDados DB = new…
-
6
votes2
answers2706
viewsA: How to use vector to store a class?
The code has some problems, I will not fix everything, but I will allow at least it to be compiled: #include <iostream> #include <string> #include <vector> using namespace std;…
-
4
votes1
answer4507
viewsA: "error: 'string' does not name a type" when declaring strings
You have to include the header of string. And the guy’s full name would be std::string, then a using is usually appropriate not to have to describe the namespace every time. In C++ the grouping of…
-
5
votes2
answers1291
viewsA: Bigdecimal comparison returns unexpected result
The point is the decimal separator, so you’re comparing 100 to 50 (50,000 read "in English" is 50,000, or simply 50). Do not use dots to separate thousands. Actually this does not exist in…
-
8
votes2
answers658
viewsA: In C++ what is the command corresponding to Java super()?
You call explicitly by the class name, because in C++ there is multiple inheritance and can have more than one ancestor. Roughly it would be this: class Teste : public Testando { String nome; int…
-
2
votes2
answers287
viewsA: How to make a function use how many arguments are provided to it
Can create this: void a(int tamanho, ...) { va_list valist; va_start(valist, tamanho); for (int i = 0; i < tamanho; i += 2) { setColor(va_arg(valist, int)); printf("%s", va_arg(valist, char *));…
-
2
votes3
answers3377
viewsA: How to eliminate excess spaces in a string?
Basically the problem is not having initialized the variable j. But logic takes away all space, I had to change a little with the alert of Jjoao in the comments. I made an optimization, organized…
-
7
votes1
answer566
viewsA: Dynamic Memory Allocation X vector
The dynamic allocation call is made in heap. This has implications on possible lifetime of the object. We are on this site, it survives the end of the function, it does not burst or overload the…
-
8
votes2
answers881
viewsA: How to avoid code repetition between classes?
I will not talk about all the aspects that could be different, how it treats exception, etc. Staying in the focus of the question has the most object oriented path or the most procedural/modular…
-
8
votes2
answers1185
viewsA: Which pattern to use: HTML5 or XHTML5?
XHTML is abandoned, all versions. Old ones are still supported by browsers. Version 5 as far as I know is not supported by any and will not be, except for things that match HTML5. The way is HTML5.…
-
3
votes1
answer524
viewsA: Java Vector Table Testing
Can you understand that? aux[counter] = aux[counter] + 1; It is the same thing. It takes the value of the element indicated by counter of array aux, adds 1 and stores in the same location, evidently…
-
3
votes1
answer2466
viewsA: Empty list matrix initialization "{ }" in C++
You can do this yes. Some compilers may complain and require a slightly different syntax: int minhaMatriz[10][10] = {{0}}; I put in the Github for future reference.…
-
4
votes2
answers539
viewsA: Context Dispose should be used in ASP.NET MVC?
You can do it the same way, but it’s not necessary. The process executed is ephemeral and there will be the release of resources after its completion, this is guaranteed by framework then the first…
-
18
votes3
answers1686
viewsA: Are there safer languages than others?
Programming languages are not inherently safe or insecure, they are a means of expression. Who has to do something safe is the programmer. Some avoid certain types of problems that cause more…
-
45
votes4
answers17728
viewsA: What is a scaffold?
What is Scaffold? Scaffold is an age-old code generation technique based on common operations templates that are used in different applications. Contrary to what many people believe, probably fruit…
-
2
votes2
answers747
viewsA: How to make database changes without having a clear primary key?
A basic technique of creating tables in a database is to have a column ID as the primary key, so the data is free to be worked as you want. This identifier which will obviously be unique and…
-
2
votes3
answers159
viewsA: Applying Interface in Controllers
If I understood correctly it would be this: public E adicionar(E Element); Otherwise, you cannot use the same interface. What you could inherit from this existing one: public interface…
-
7
votes1
answer666
viewsA: Passing optional arguments in Java
Essentially it is answered in question by Renan Gomes. And it is good to say that the parameter is not optional, the arguments are that can be (see the difference between them). As in the background…
-
6
votes1
answer2557
viewsA: Remove spaces via Update
Using the function TRIM(): UPDATE INTO noticiais SET titulo = TRIM(titulo); I put in the Github for future reference.…
-
1
votes1
answer97
viewsA: What are the Ibraries?
It is not possible to know, because in my Windows there is no obvious. It also has little or no importance to know exactly what is being asked. Depending on the context, it could be something…
-
7
votes2
answers8240
viewsA: Double quote character removal "
Do the Replace(): texto.Replace("\"", ""); I put in the Github for future reference.…
-
3
votes1
answer386
viewsA: Recover Volume Name of Netmapped Disk Drive
Apparently the way to do this is with WMI, according to this response in the OS. Test with this code to see if it returns what you want and adapt to what you need. var searcher = new…
-
5
votes2
answers11304
viewsA: What are the differences between the values "en" and "en-BR" of the lang attribute?
When informing only the language, that content will be used in specific tools configured for that language. When informing the language and the regional dialect the content will be used only in the…
-
5
votes1
answer74
viewsA: Attribute Translate: what will be the use of this future attribute?
No one can adequately answer the first part. The second part, at its core, will also serve no purpose. Futurology is not the goal here. The attribute translate serves to give semantics to the…
-
3
votes1
answer48
viewsA: Understanding the concept of export Symbols in shared libraries
Usually this is defined by the compilation. So normally it is defined by Make, another software build tool or by script which calls the compiler or the simple GCC command line. There are other…
-
9
votes2
answers1007
viewsA: How does a method that can receive multiple parameters work?
You can look at the his source code to see. This mechanism is a parameter with variable number of arguments. The quantity is virtually unlimited and can be used in any method you want, as long as it…
-
4
votes1
answer1193
viewsA: Create class inheritance
The statement does not give many details, so I have to consider that a lot of things are right, even if I would not do it in real code, and the code does things that the statement does not ask for.…
-
4
votes1
answer140
viewsA: Is it correct to omit the "true" value of the Boolean attributes inserted in the HTML elements?
In fact the correct according to the specification is that it does not have the string indicating true or false. The main browsers interpret these boolean values, but it is out of the standard, it…
-
4
votes1
answer123
viewsA: Private variable error in C++
The line for (int i = 0; i < array.length; i++) { is accessing a call property length in the class, but it is declared as private and therefore cannot be accessed. The solution could be to make…
-
4
votes2
answers590
viewsA: A person can have multiple phones. How to do this with vector and not with list?
There are better ways to assemble the classes, but without wanting to mess with the structure and directly answering the question, I would do so: public static void main(String[] args) { Pessoa…
-
5
votes1
answer457
viewsA: How to create a Custom Attribute?
First there is a mistake in thinking that the attributes of C# are equivalent to decorators of Python, the operation of both are quite different. The attribute is just static information, it’s a…
-
11
votes3
answers8991
viewsA: What language is used to program an operating system?
Essentially anyone you want. In a certain way it is possible to write an unconventional operating system even with JS, although it is a bad language for this and there will be strong limitations.…
-
5
votes2
answers339
viewsA: How to completely delete an Arraylist and a List
The best way to do this is to create a new instance: ArrayList<Elemento> e = new ArrayList(); //Elemento e uma classe for (int i = 0; i<10;i++) { e.add(new Elemento()); e.get(i).texto =…
-
2
votes1
answer169
viewsA: Is outputcache only valid at controller level?
Like the name says, it’s an output cache. This means that if you receive the same request that has been made before, instead of processing all this, it takes the final result - which is already in…
-
2
votes1
answer439
views -
13
votes2
answers847
viewsA: How does running an . NET application work?
The .NET Compiler Platform (formerly called Roslyn) is used as the basis of the C# or VB.NET code compiler. This can be understood in the question What is a programming language, IDE and compiler?.…
-
4
votes1
answer411
viewsA: Singleton standard for database communication
The Singleton pattern is just that (it can eventually be a little more sophisticated). Because it is static there is no actual instantiation, and the logic of the method ensures that the connection…
-
3
votes1
answer264
viewsA: How to select more than one txt file with C#
Just set up the property Multiselect. The result will be returned in the property Filenames (plural) which is a array of strings: private void btnSelecionarArquivos_Click(object sender, EventArgs e)…
-
6
votes3
answers603
viewsA: Problem sorting an array with Sort()
Javascript treats the elements as string, so the "problem" happens. Solution: var a = [44, 7, 5, 6, 4, 2, 1]; a.sort(function(a, b) { return a - b; }); console.log(a); I put in the Github for future…
-
9
votes2
answers1332
viewsA: Convert string to Datetime in LINQ
First, you should only wear one Parse() if you are sure that the format cannot fail. Otherwise you need to use a TryParse(), which would require an auxiliary method if you want to use in LINQ. If…
-
1
votes3
answers8393
viewsA: Zeroing position of a vector to ensure there is no dirt
If you’re gonna use array really, just do this: std::fill_n(array, 100, 0); Some compilers may adopt an extra alternative syntax: int array[100] = {0}; or int array[100] = {}; or int array[100] = {…