Posts by Maniero • 444,682 points
6,921 posts
-
7
votes2
answers104
viewsA: Error in "break" in C++ code prevents compilation
I don’t know if you don’t have what’s wrong, but the code says typos, missing the ; after each break. Organizing the code a little better would look like this: #include <iostream> using…
-
3
votes2
answers377
viewsA: Decimal places in Javascript
Javascript only has a numeric type, so it should use it. And of course, it has a maximum and it is this maximum that you can use. It is good to know that JS uses a numerical type based on binary…
-
4
votes1
answer51
viewsA: Copy and move constructors are called only in the creation of an object?
Yes, they’re still builders. After creating an object with it if you call the constructor it will create another object, each independent of the other. Or almost, the m_ ptr of each of them will…
-
3
votes1
answer469
viewsA: Convert an object that implements the interface into its own interface
If you change this line it works: public class ClasseTeste : Teste<IRegistro> Another possibility is to make the parameters of Metodo2() and Metodo3() are: IBase<Registro> I put in the…
-
8
votes2
answers760
viewsA: Instantiate class with Static method
There are some conceptual errors in the question and the comment of the PA in the other question is important, but in reverse. The Program class was created automatically next to the Static void…
-
6
votes2
answers67
viewsA: What is the best performance in comparison of string sizes?
First, you shouldn’t wear Strings.len(), this is something used in the Visual Basic compatibilization library and, although possible, it should not be used in new code, especially in C#. Not that it…
-
4
votes1
answer1038
viewsA: I would like to understand what OLTP is
There are basically two models of access/data processing in the database, the OLTP (Online Transaction Processing) and the OLAP (Online Analytical Processing). OLTP is what almost everyone does,…
-
6
votes3
answers608
viewsA: Read a console line in C#
Working is different from being right and this is one of the most important things you need to learn in software development. In this case if someone enters something wrong will break the program,…
-
2
votes3
answers1421
viewsA: Compare if two date fields are equal in C#
The accepted solution will break the application whenever someone enters a wrong format, so it works: if (!datetime.TryParse(CampoData1.text, out var data1)) //faz o tratamento de erro aqui if…
-
4
votes1
answer112
viewsA: What is the safest way to display ID (primary BD key) on web pages?
It makes no sense to encrypt this since the unencrypted information will be available in the client. Facebook does not encrypt anything even because the engineers who work there know that it has…
-
3
votes2
answers138
viewsA: Are variables declared within blocks or subprograms dynamically allocated?
The term dynamic allocation is not usually used in this context. In a way it is true. This type of allocation occurs in the pile, then it always occurs at runtime, in this aspect we can say that the…
-
1
votes3
answers259
viewsA: Problem with recursive function, 2 parameters
(potencia(i , j) <qual operador vai aqui?> i * j - 1) You can’t have two operands without one operator. Missing put what needs to be done with the power of e and j related to i. Putting an…
-
1
votes1
answer86
viewsA: Difference between closures and functions
A function is something much simpler. A closure presupposes more things. It certainly uses a function, but it needs to be first-order, meaning it needs to be able to be used as data, it can be used…
-
5
votes3
answers318
viewsA: Indentation in statement "Else"
In the first case the else is not from if is from for. If the for not interrupted then falls into the else. So in this case if the i be less than 2 o else will be executed, which seems to me to make…
-
13
votes4
answers1780
viewsA: After all, why does the PHP source code not appear in the browser?
Nothing is safe if you don’t know what you’re doing. Almost all the sites on the Internet today are insecure because almost all of them are made by people who think they can decorate cake recipes…
-
1
votes2
answers138
viewsA: Automatic cast with Typescript?
Can use: result.data.is_correct == "1" var x = "1"; console.log(x == "1"); x = "0"; console.log(x == "1"); I put in the Github for future reference.…
-
1
votes2
answers173
viewsA: What is the logic of python for i 'in'
In this case there is no typing, but it can be elsewhere. The for is an internally controlled loop, it knows where to start (0) and where to end (the size of the data collection). One string Python…
-
5
votes2
answers663
viewsA: Where to create a Helpers layer?
Right or wrong in these things is relative. Everything works and in general is not falling apart. It is often precious to try to do so right so long as know what you’re doing. Without knowing even…
-
17
votes1
answer380
viewsA: Traits and mixins, what are they? When should I use them? Are there similar mechanisms in other languages?
Each language implemented and called trait what you understood well. It is one of those things that nobody knows to define for sure. So much trait as mixin are code reuse techniques, both make…
-
12
votes2
answers1026
viewsA: Can a subclass have two superclasses?
Anthony Accioly’s answer answers the question correctly, I will supplement it. Java has multiple inheritance of subtype, but not subclass, that is, you may have several types in your class, but you…
-
2
votes2
answers141
viewsA: How to make a multiple variable definition in VB.net
It is not possible to do this in VB.NET, the most that gives is to put everything in the same line, but they will be completely separate assignments. In fact it is almost always something that…
-
5
votes2
answers477
viewsA: Why is the variable not modified?
If you declare that the variable is external (global) it works, but do not do this, if you need to work with a value that comes from outside receive it as parameter. variavel = 0 def valores():…
-
1
votes1
answer164
viewsA: Pass vector as argument to a function
This code doesn’t make much sense, the question makes even less. It’s not passing a vector, it’s passing a unique value. If you want to pass an array do this and treat it, but everything indicates…
-
18
votes5
answers3081
viewsA: How to decide between using for or foreach?
I’ll talk about collections, but understand that they are all sorts enumerable. Semantics It’s a semantic question. You’re going through a collection (array, list, string, dictionary, JSON…
-
3
votes3
answers737
viewsA: Temperature converter
Whenever using a numeric literal make sure to be the literal of the right type. In type float the literal always has a decimal point and ends with a f or F. Its division of 5 by 9 is using integers,…
-
1
votes2
answers3022
viewsA: Repeat number check on matrix in C
The problem is that the bond of ii must be <=, because you need to check when it’s 0 too, you can’t skip row and column at the same time. I did the right thing and to simplify separated into…
-
1
votes1
answer74
views -
4
votes1
answer117
viewsA: What is the best way to post comments?
Only you can say which is the best way for your case. The first form can be very interesting and many people think it is not. Ask a few questions: You need to access the comment in isolation or it…
-
5
votes1
answer304
viewsA: What are the delegates?
Much of this is more or less answered in What is the difference between a lambda expression, a closure and a delegate?. Roughly speaking it’s a pointer to a function, it’s a indirect, so you can put…
-
2
votes1
answer42
views -
16
votes5
answers453
viewsA: How to separate "words" in Camelcase in C#?
Option more performative, flexible, integrated and more correct according to the criterion that one already has a separator should not put another: using static System.Console; using System.Text;…
-
5
votes1
answer110
viewsA: How to stop printing positions = 0 of a vector?
Whenever you need to filter something you should if: for (var i = 0 ; i < 9 ; i++) if (calculo[i] != 0) WriteLine(calculo[i]); Or you can do foreach (var item in calculo) if (item != 0)…
-
3
votes1
answer84
viewsA: What is the fastest way to build text?
The first undoubtedly because it in practice is the same as sb.append("oimeu nomeéJonny"); If it’s with variables it’s the same as: sb.append(string.Concat(v1, v2, v3, v4)); I put in the Github for…
-
2
votes1
answer684
viewsA: What is the best way to record a user log?
Only you can answer what’s best for you. Actually it is much easier to do in Mysql and fully feasible, even HTTP servers use this, though not by default. Making into a file can be more performative.…
-
8
votes2
answers1848
viewsA: Treat division by zero
First, you shouldn’t wear eval(). You have to have a very strong domain in programming to use it smoothly. And whoever has this domain always finds a better solution. Division by zero is considered…
-
1
votes2
answers71
viewsA: How to control version number on budget?
It’s simple, consider each version as a different budget, having information that identifies which version it is. You know the latter is worth. It may even have some mechanism to freeze edits. Of…
-
3
votes2
answers350
viewsA: How does PHP run time work?
On the server, php code is executed at each request or it is always working? Yes, as with any technology, there is no way anything can work without being executed every time that activity is…
-
3
votes2
answers116
viewsA: Is there any way to simplify this amount of conditions?
Yes, it does, quite: var deslocamento = lote.AlvoPasso / ushort.MaxValue; dadosBalanca[3] = deslocamento; dadosBalanca[4] = lote.AlvoPasso - ushort.MaxValue * deslocamento; I put in the Github for…
-
1
votes1
answer68
viewsA: Keep stack trace when the method gives rethrow in the captured Exception
Yes it is better to use throw than throw e because it doesn’t destroy the stack trace and gives better information about the error, but maybe the right thing is not to have this try-catch. If you…
-
6
votes2
answers170
viewsA: Switch only enters "default"
Just do this: jj = Console.Read() - 48; I put in the Github for future reference. Character 0 is 48, so doing this account does not need to convert anything, does not complicate, and works as…
-
1
votes2
answers1707
viewsA: Table structure in user questions and answers template
Your question is above average, but it is still difficult to state something without knowing the needs. My primary understanding is that 2 is better, an answer should be linked to the form and not…
-
4
votes1
answer286
viewsA: C/C++ libraries and preprocessing
Without the #include really gets very complicated, even if possible. I do not know if they say not to use even this, I imagine they speak of other things. Because C/C++ languages do not support the…
-
14
votes3
answers1710
viewsA: What are the limitations of the object-oriented paradigm?
It can produce useful information here, but our mechanism does not help people understand that this information is not canonical and universal, which reflects some bias First let’s agree on who uses…
-
10
votes2
answers2984
viewsA: Surrogate Key and Natural Key
To replacement key (surrogate) or artificial is a data that is created for database control purposes, it does not exist outside of the software solution being developed. It’s usually a single,…
-
3
votes1
answer115
viewsA: Can any generated exe run or depend on the platform that was made?
Depends on the platform. An executable is a set of instructions that determine what the machine should do, so if it uses instructions that a platform doesn’t understand won’t work. It’s like saying…
-
37
votes3
answers2737
viewsQ: How to integrate microservices?
The idea of microservices is good. But I don’t really understand how to solve certain problems. Maybe the problem is how it is "sold". I don’t see much to say when to use it or when to avoid it. It…
-
1
votes1
answer395
viewsA: What is the difference between Table and Matrix and List in Report View?
According to the documentation: Table It’s a columnar report. It works like a perfect matrix. It is possible to make some settings, but it is that classic report with rows and columns. Today it’s…
-
3
votes2
answers358
viewsA: Good Practice for Rest Services
Forget this good practice business. It only uses this two kinds of programmers: the one who doesn’t understand what they’re doing and will use everything wrong, or the very experienced programmer…
-
2
votes1
answer236
viewsA: Traverse an array using malloc
What is really happening in this example? For all intents and purposes you are accessing a array, albeit technically the definition is a little different. In C the array is always accessed via…
-
1
votes1
answer288
viewsA: Pass values by reference C
The code has several errors, I think that’s what you want: #include <stdio.h> typedef struct { int numero; char nome[100]; char morada[100]; int idade; int telefone; //o tipo está errado }…