Posts by Maniero • 444,682 points
6,921 posts
-
1
votes1
answer35
viewsA: How to make an internal calculation in Textbox?
The first problem is that it is considering that the person will always type something right, which can not guarantee and will break the application, have to treat it. With a valid data is just to…
-
9
votes3
answers126
viewsA: Why does type "any" exist in Typescript?
The two lines give the same result, but they are not the same thing. There is an explicit semantics in the first line, which is more readable and shows that the intention is precisely this. If…
-
5
votes1
answer127
viewsA: What are types in the return of a method?
The question is confusing and shows that you are learning without a structure. This does not work, you learn everything by half, wrong things, skips steps. It’s like building a house without a…
-
4
votes3
answers100
viewsA: What are the advantages of using a database instead of a JSON file to write data?
A database was made to store data, so by itself should be enough advantage to think about adopting it. You may think that JSON is also for storing data, but no, and this has been answered before, as…
database modeling software-engineering software-architecture language-independentanswered Maniero 444,682 -
5
votes1
answer65
viewsA: A client class that registers clients in itself would be a cohesive class?
The simple answer is no. But the logic presented for not doing so is not quite this. The deeper answer is: it depends. Always. The most common mistake people make is wanting to define something…
-
7
votes1
answer110
viewsA: Why, in C, is a statically declared array name not an lvalue?
Read Arrays are pointers?. This explains the exception for this case. Change the value of a array statically declared would violate the definition of array. All other cases you have a direct…
-
3
votes1
answer89
viewsA: Function that takes a string and converts it to uppercase letters gives error
This is not possible because you are trying to write to static area of memory. You should create text in a dynamic area and then modify it. Or copy the static area text to a dynamic area. Or not…
-
0
votes1
answer39
viewsA: What does the context class do for the Strategy design standard?
What is defined as contexto in this pattern is just a generic way of calling the class that you will use the strategy. It’s where you need a strategy and possibly the choice which one to use. For…
-
4
votes4
answers4635
viewsA: To what extent is it not advisable to use an ORM?
The question is very opinionated, at the time was well accepted, has opinions here and decided by mine that is different. Why use ORM is an excellent tool to give some productivity to create Cruds…
-
3
votes1
answer51
viewsA: Why use a pointer to struct instead of the struct itself in this case?
It can have many reasons, including several wrong ones. It seems to be an exercise that asks to do this. If he asks, he should explain why, if he doesn’t explain, it’s not a good exercise. Pointer…
-
1
votes1
answer52
viewsA: Relationship between microservices
One of the reasons you still don’t understand the concept is that you still think of it as a macroservice. Inventory Control is a microservice?!?! There is no size definition for a microservice, but…
-
6
votes6
answers47964
viewsA: What is JSON? What is it for and how does it work?
JSON is the acronym for Javascript Object Notation. This means that it uses text formatting that is similar to the declaration syntax of an object in Javascript language. This text can be used in…
-
5
votes1
answer32
viewsA: When creating a new pair in a dictionary lose the previous data?
You are not creating a new key and value pair, you are creating a new dictionary and saving in it variable, so its previous value is lost, since it cannot store two different values in the same…
-
1
votes1
answer40
viewsA: Stringbuilder append() converts to string automatically
Let’s see the documentation of AppendLine() and of Append(), which by the way is what should always be done before using any language/technology resource adopted and its Apis. There it shows that…
-
4
votes1
answer67
viewsA: What is the syntax that comes before the variable name in function parameters?
In both cases it is the type of the variables being declared there, in the specific case of the example the variable is a parameter, then the variable will be typed, it should only be used with…
-
3
votes1
answer36
viewsA: If the class ofstream is to write to files, ifstream to read and fstream to both cases, why not always use fstream at once?
fstream serves to read and write to files (can even create if it does not exist), does not serve to delete files. Under normal conditions, there’s nothing wrong with that. Some people prefer to make…
-
2
votes2
answers84
viewsA: Is there a difference between "accuracy" and "precision" in computing contexts?
I have never seen anything specific to all computation. At specific points in computation it may be that the term has some specificity (in fact has definition) or may have used it in a certain way,…
-
3
votes3
answers75
viewsA: Store data in DB vertically or horizontally?
Both can be used, of course. One is the formally correct, the other can give more efficiency in the system, in addition to the differences already noted by the author of the question. One table,…
-
0
votes1
answer36
viewsA: Invoking methods within an Arraylist does not recognize the object method
Here is the class documentation Object which was the guy you used to store objects in ArrayList. Where is the method getNome() in it? If it has not you can not call, it is not available. You must…
-
2
votes1
answer56
viewsA: Perform function according to dictionary key
You cannot use functions directly like this, because when creating the dictionary is calling the function, then the value stored in the key will be the result of the function that is called, and…
-
2
votes1
answer63
viewsA: How to capture several exceptions with C#switch?
switch does not serve to capture exception, the catch serves this purpose. If you have one action for each captured exception then just use several catches. They function similarly to switch and…
-
1
votes2
answers57
viewsA: What is the correct definition of concatenation and what really happens when we do this with variables?
First read this: What is a variable?. You do not sum or concatenate or do any operation with variables, but rather do with values, which eventually are stored in variables or in objects that are…
-
0
votes1
answer41
viewsA: How to create optional parameters in C++?
C++ has standard arguments (the correct term, see more). And you can write more succinctly if you want, only it can’t be smaller because C++ is not a language of script by default, so it makes no…
-
2
votes3
answers105
viewsA: How to change the value of a variable with a function?
In general it doesn’t make much sense to do that, but if you really want to do the way of doing it is to pass the value by reference. More details on the subject at Memory allocation in C# - Value…
-
4
votes2
answers96
viewsA: A class is an instance?
Generally speaking, it is not. What is the difference between a class and an object?. Object in the case is the instance. Just to make something clear before: p1 is a variable. It has a value, so…
-
5
votes2
answers99
viewsA: Why is it necessary to instantiate a Python class when I can call it directly?
First, classes are not required in some cases, even if people use where they don’t need to. Classes should create the object model that serves for something useful, so it needs to be very well…
-
5
votes1
answer56
viewsA: Can LLVM be used with the C language?
LLVM is a backend compilation, i.e., it takes an intermediate language that is specified along its entire ecosystem and creates a target code for some platform, which can be code native to some…
-
4
votes2
answers67
viewsA: Is there practical application in write-only properties?
First read this: What is the difference between attribute and field in the classes?. This indicates that you want to let the consumer assign a value to the object and then not let it move anymore,…
oop characteristic-language software-engineering property language-independentanswered Maniero 444,682 -
2
votes2
answers46
viewsA: How to iterate over a string by obtaining the indices of each character in C++?
enum is not a function. See documentation his. The simplest way to do this is to add an external counter to keep track, it’s not the most beautiful solution, but it works: #include <iostream>…
-
3
votes1
answer53
viewsA: How to convert an entire string to uppercase characters without using loop?
There is nothing ready, you have to write the code, as you did (although it is not a very good idea for efficiency since it changes the size of the string, but that does not affect an exercise, even…
-
3
votes2
answers46
viewsA: Enum initialization
This case changes nothing. It just adopted the more explicit style than the compiler already does by default. When nothing is informed the first value is always 0 and the others remains always the…
-
5
votes1
answer68
viewsA: "strlen()" works with literal but not string type variable
"Teste" by default is a type char *, is not a guy string. I mean, it’s C’s way of creating a string, is not the form of C++. And if you will use the form of C then the strlen(), which is a C…
-
5
votes2
answers114
viewsA: Is there a way to interpolate strings in Java?
In Java you have the class Formatter for this. And in fact it is more suitable in various situations. There are other options, the class itself string has a. I just wouldn’t say she’s less tiresome.…
-
5
votes2
answers84
viewsA: How to return the last character of a String in C++?
C++ does not have this syntax. Use back(). Always look at the documentation of what you are using to find out what is available to that object. And note that this method gives you the character by…
-
2
votes1
answer144
viewsA: Is the conditional structure "if Else" more performative than a "switch case"?
Not by a long shot. It is not possible to guarantee anything because there are different ways of use, some mistaken but still possible, besides that the form of the implementation is not something…
-
7
votes1
answer68
viewsA: Are Java enumerations anti-performance?
Yes, the enumeration of Java is a class, so an object heavier than a pure and simple number, and even worse, a class is allocated in the heap that puts pressure on Garbage Collector, as any object…
-
5
votes1
answer74
viewsA: What is Clone-on-write (Cow)?
The concept is actually quite simple, but the use in Rust is not so much, as almost everything in Rust. The technique of copying when writing has to do with immutability (plus), then you have an…
-
3
votes1
answer83
views -
3
votes1
answer39
views -
1
votes1
answer107
viewsA: How to concatenate two strings into C without using <string library. h>?
So you have to figure out where the first position is array ends, and the first loop even does this, but then everything gets confused, because that’s just what you should do in it, should not have…
-
1
votes3
answers188
viewsA: Two classes or more in the same element in HTML
You can’t have two attributes class in tag, but you can have as many classes as you want, and that’s very common: <div class="primeira_classe segunda_classe"></div>…
-
4
votes3
answers103
viewsA: Am I doing polymorphism the right way?
This is conceptually wrong, and using the term you used in the question, it’s a bad practice (although I don’t like it because it makes people think it’s a magic rule). At least that’s what I can…
-
5
votes1
answer71
viewsA: What is the difference between two code snippets with and without a constructor?
It would be interesting to see this: What good is a builder?. When you initialize a field in the class you’re saying that you want the compiler to write a constructor for you where it initializes…
-
3
votes1
answer58
viewsA: Is it recommended to use typedef in C++?
The typedef is one of the things C doesn’t use much in C++, but it depends on the situation. The definition of a struct already is typedefed (every compound structure definition is already a type…
-
3
votes1
answer81
viewsA: Is it correct to use an object to call a method where it will be the parameter?
Maybe, but almost always not, probably has a mistake of design there. You should see why you have a parameter in this method if the intention is to modify the object itself. Or see why it has a…
-
2
votes1
answer69
viewsA: How do I use the semicolon in the "for" command?
The semicolon is a finalizer of statement (plus). It’s not the end of the line or anything else that ends it, only that character does it, no matter where it is, it can even be on another line. Now…
-
7
votes1
answer72
viewsA: Use the anonymous typedef or not?
Okay, let’s jump in the part you already know (or this). That’s all it is, the structure is anonymous and so you can’t use it directly anywhere that requires it. I don’t know if you know but it is…
-
5
votes1
answer58
viewsA: What is the criterion of Java in having in some cases, a class in its API and in other cases an interface?
Basically the same criterion that anyone should adopt when creating a Java application or the criterion to be adopted in another language, this concept is universal and should not depend on…
-
3
votes1
answer68
viewsA: What are dependent types and dependent language?
What are dependent types? It is the type that depends on its value and not just the general qualification of what fits there. The most typical example is the type that allows establishing a range of…
characteristic-language typing language-independent computer-science type-theoryanswered Maniero 444,682 -
3
votes3
answers59
views