Posts by Maniero • 444,682 points
6,921 posts
-
8
votes3
answers168
viewsA: Why is it necessary to create a function to execute certain methods?
Why you need to create a number or a string or a array, or any other object? Why does the problem ask for that, right? It’s the same thing. You have a problem that requires a function, so you have…
-
9
votes3
answers845
viewsA: How to declare a constant in Ruby?
One of the things I like about Ruby is the adoption of philosophy Convention over Configuration. This means that there is a way that you use something and language knows what to do, to the detriment…
-
5
votes5
answers2297
views -
2
votes1
answer106
viewsA: What is the purpose of the "[Bind("ID,Title,Releasedate,Genre,Price")]" feature in a method?
What kind of feature is the [Bind("ID,Title,Releasedate,Genre,Price")] statement passed in the Create method signature? Are attributes. Can be used in other parts of the code. What would be the…
-
5
votes2
answers460
viewsA: Recursive or loop method to popular or list an n-dimensional array
It is very difficult to have real problems with more than 3 or 4 dimensions. If you have a problem like this or it is set wrong or it is better to find a different solution. Even if you have a…
-
2
votes2
answers476
viewsA: Doubt Console.Readline
The right way to do it is like this: using static System.Console; public class Program { public static void Main() { WriteLine("Digite o ID do artista:"); if (int.TryParse(ReadLine(), out var…
-
1
votes1
answer300
viewsA: Break text and vector store
Then it starts to get complicated. I made changes that solve the problem, but I don’t even know if it’s what you need, there’s no clear definition of the problem. I interpreted that every line break…
-
3
votes1
answer98
viewsA: How does malloc() organize memory?
The allocation by malloc() is equal to array from the point of view of the question, it is all continuous, when allocating a data sequence. Well, physically it may not be so because of the virtual…
-
3
votes2
answers349
viewsA: Dynamic matrix creation that stores broken text
The answer of Isac is correct. I decided to only give an option that gives greater speed efficiency by paying the price of fragmenting more memory. Whether it is a better option is debatable and…
-
2
votes1
answer53
viewsA: How do I make the methods receive the x and y parameters?
I imagine this is what you wish: import java.util.Scanner; class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Informe dois valores: ");…
-
5
votes2
answers202
viewsA: Why do we pass an object to the statement lock?
This has to do with atomicity. This ensures that the object cannot be accessed by other parts of the code concurrently until it is released, thus ensuring that the intermediate state it is in…
-
5
votes2
answers91
viewsA: Checking whether data persisted successfully
It depends on the type of problem you expect to have. If it’s just logic error it seems to me that this is the best way even. It already says if any operation persisted or not. But it may not have…
-
2
votes2
answers47
viewsA: Struct array accepting more than defined, what’s wrong?
Completely normal. That’s C, you do what you want and the language leaves. Of course you’re corrupting the memory and you shouldn’t be doing that, but it’s allowed. It works, but it’s not right, in…
-
4
votes1
answer106
viewsA: I don’t understand the order to execute a code
When the application starts running at some point it will initialize the static members. It is guaranteed that this occurs before any class instance is initialized. Then creates the variable result…
-
5
votes2
answers260
viewsA: How to save changeable parameters in the system?
Group the parameters by categories and create a table for each of them, placing a record where the columns would have the value of each category parameter, this record could be changed at any time.…
-
4
votes1
answer860
viewsA: Fibonacci issue in Java
Actually I think you need a course with the basics of logic and algorithm before you try to understand this. I redid the code because it is very wrong. I put better names in the variables that helps…
-
4
votes1
answer275
viewsA: Pass complex object vs simplest object per parameter
Overall consumption makes no difference. It can have side consequences, but it depends on a lot of things and I don’t think it would still matter. At least for this case I don’t see it happening.…
-
3
votes1
answer115
viewsA: Division does not generate the expected result
It is a typing problem. The two variables of the division are integer, so the result is an integer. You need to make a cast for float before making the split. It was hard to come to this conclusion…
-
4
votes1
answer115
viewsA: Why does bitmap indexing work well for low cardinality domains?
In fact it depends on the implementation and the objective of the index. Generally the goal is to reduce the space occupied in the index and give better performance, in addition to maintaining a…
-
19
votes4
answers1634
viewsA: What does the term "atomic" mean?
Atomic comes from the atom, that is, something that is indivisible. In computing we use the term when something is guaranteed to be done completely, you can’t just do a part, even if you have to…
-
5
votes3
answers1309
viewsA: I want to change a string in 3 positions
You have to convert to number to make the account (with ord()) and then convert to character again (with chr()), thus: def DeslocaASCII(texto): novoTexto = '' for letra in texto: numero = ord(letra)…
-
4
votes1
answer281
viewsA: Application of algorithms in POO
Object-oriented programming has nothing to do with algorithm, it has to do with data structure. Of course, how you structure the data affects how you do the algorithm, but it’s more about the…
-
9
votes2
answers1573
viewsA: What is the advantage of a 1:1 relationship?
In the commentary I think you are talking about the relationship N:1. Many people confuse it with 1:1. Unless the text is just confused because of the short maximum space imposed. The N:1 is because…
-
5
votes2
answers927
viewsA: What’s the difference when creating a class libray (.net framework) and class library(.net standard) project in VS2017?
If you choose . NET Standard you can only use the features listed in this specification. Anything that is not on it will generate an error. Note that it only has the list of components, it does not…
-
1
votes2
answers59
viewsA: Taskcompletionsource<Tresult> without a type parameter
There is no better form today. There is no TaskCompletionSource without a result to be defined. What may be a gain, but I have doubts is to return a type by value and not object to avoid allocation…
-
3
votes2
answers66
viewsA: Is indexing sites by half possible?
The question talks about two things, partial indexing of the site and partial indexing of the page. Yes, you can use robots.txt or the meta name="robots" to indicate what you do not want to index.…
-
2
votes1
answer51
viewsA: Syntax error in final key
This method is within another method, if you take it out and leave it at the class level it should solve: public static List<TSource> ToList<TSource>(this DataTable dataTable) where…
-
1
votes2
answers235
viewsA: Reset variable every time you switch to a method
If you want to keep the state of the variable between the methods you need to send and receive. That would be: import java.util.Formatter; import java.util.Scanner; /** * * @author…
-
2
votes1
answer44
viewsA: Console write 2 strings from the list
Because you are only having the first element printed, if you want to print the two elements you need to have it explicitly printed. So: WriteLine(${lista[0] - lista[1]}); Note that he is not…
-
8
votes2
answers684
viewsA: Use of interfaces in domain classes?
Introducing I’ve been worried a lot about software modeling lately. I’ve been trying to improve my understanding of object orientation to go beyond what people think this paradigm is, and that…
-
30
votes3
answers814
viewsQ: How and when to build an object in valid state?
Think of a large class, a complete customer registration for example. It has a huge amount of attributes in it. Many of them need to be initialized in the construction of the object in order for the…
-
3
votes3
answers69
viewsA: Program does not meet expected flow by reading and printing input
The biggest problem is that you are not passing the address of the variable where the value should be placed in the scanf(). This function needs to know where to put the entered value. Passing the…
-
5
votes2
answers178
viewsA: Duck type in Elixir
You’re assigning a list with 3 values to a list with elements, two of them are values, so it doesn’t make sense to use it that way. The only element that serves any purpose is the variable a. Then…
-
3
votes1
answer148
viewsA: Convert Dynamic to query string
First, you should use what is ready to encode the URL (.NET Framework and .NET Core). You should not create an extension method on object, will be available for everything and I think you have no…
-
4
votes1
answer1406
viewsA: Doubt about System.currentTimeMillis()
It comes from the operating system. The OS is loaded and picks up an initial state contained in the machine’s memory (it needs to have a battery or be on) and/or an external source (internet or…
-
1
votes3
answers196
viewsA: Is it possible to store values without using static vectors?
Yes, there are several ways to do this. And one of them is the static vector itself. Yes, it is possible to create something rhythm that manipulates the vector creating another one when you need to…
-
5
votes2
answers1493
viewsA: Syntax difference between databases
There’s something called SQL ANSI. ANSI is a standardization entity of the United States, equivalent to our ABNT. In fact there is an entity called ISO that is the world standardizing entity. In…
-
17
votes3
answers5645
viewsA: What is the purpose of declaring a function within a function?
One reason is encapsulation. If the internal function will be called only by this function there is no need to put out. Putting inside ensures that no one else can call. One thing I notice is that…
-
5
votes2
answers1451
viewsA: I need to know when the user uses semicolons in decimal numbers
You have to use the method that allows you to specify formats. See TryParse(). Any other solution is gambiarra. Even this one needs to be well thought out. Imagine if the user type both the dot, and…
-
7
votes1
answer190
viewsA: Division always resulting in zero
You are doing a division of integers, so the result is entire, even if you then store it in a double. Then divide a double, thus: return 2.0 / (values.length + 1); Behold working in the ideone. And…
-
2
votes3
answers1181
viewsA: How to access the elements of a list declared in a different class?
You have to return the list so that the consumer can use it. So: using static System.Console; using System.Collections.Generic; public class Program { public static void Main() =>…
-
8
votes2
answers1249
viewsA: Returning function string directly and with array
The first is returning a pointer to a static area of code that is always available. The text already exists within the executable. The second is returning a pointer to an area of the stack, which…
-
1
votes1
answer265
viewsA: Execution in multiprocessors
To thread exists to allow concurrent processing. There are no guarantees that the execution will be done on different processors. It is guaranteed that if you have only the thread main will only run…
-
4
votes2
answers200
viewsA: Is there any way to implement an interface in a class of a DLL that I can only read?
Even C# 7 is not possible. Even when you can there will be restrictions, not yet fully defined, of what you can do. To test has how to access the method if you know that it is implemented, it is not…
-
2
votes1
answer112
viewsA: How to transform a text into an identifier name?
It’s possible. You need to know eval(), exec() and compile(), but don’t do such a trick. There is always a better solution unless what you want is to execute an externally entered code, which is…
-
2
votes2
answers138
viewsA: C# conversion error
You didn’t post the class Conta, but you can already tell that it does not implement ITributavel, so there’s no way to use an object like Conta in a parameter that expects a ITributavel. If you…
-
3
votes1
answer132
viewsA: Are variables randomly allocated in memory?
Randomly is never the term, always has a certain determinism, just no way to anticipate where exactly when writing code, only at runtime. And I’m going to talk here about virtual memory, physical…
-
2
votes1
answer62
viewsA: Error in the average calculation of a student record
Change structure for this that must solve: typedef struct { int matricula; char nome[80]; int datanasc; float not1; float not2; float media; Data aniv; } Alunos; I put in the Github for future…
-
1
votes1
answer3703
viewsA: How to get the encoding type of a file?
You will have to read the file to know then it probably pays to read otherwise. Using the StreamReader and read at least one part can discover with the property CurrentEncoding. But they say she…
-
3
votes2
answers398
viewsA: What is the best way to authenticate in the database?
There is no best way. There is the most suitable for your situation. If you want to know which is the safest is to use database authentication, although other ways can be very safe if you do it…