Posts by Maniero • 444,682 points
6,921 posts
-
18
votes1
answer332
viewsA: How to know if path exists?
By the code presented the correct way to treat this is by capturing the exception generated after trying to use the path. Not doing this may incur running condition, so other forms produce codes…
-
2
votes1
answer151
viewsA: File lost in Xcode
In general Ides organize projects internally and to add a file to the project you need to do perl IDE, you cannot just paste into the project folder. It is questionable for an IDE to monitor the…
-
4
votes1
answer69
viewsA: Does the size of the URL influence the rankings of search Engines?
Until someone proves otherwise or changes, since this is volatile, there is nothing to indicate that the size itself affects positioning in the search. Content does affect and being small or large…
-
4
votes2
answers269
views -
2
votes2
answers565
viewsA: Improper Infinite Loop no while
This code has several errors and does not even compile, and some bad practices ,so note all changes. The main problem is that much of what should be inside the loop is outside, as there is no…
-
5
votes1
answer557
viewsA: Is it recommended to manipulate rules with "Try-catch"?
Exception has nothing to do with object-oriented language, these concepts are completely orthogonal. There is OO spoken language that has no exception and non-OO language that has exception. There…
-
4
votes2
answers872
viewsA: What are anonymous methods and what is their main purpose?
Anonymous method is a nameless method, it is a method that does not have a symbol associated with it at compile time. You have only one reference to the code and this reference can be assigned to a…
-
4
votes1
answer165
viewsA: I’m trying to apply object orientation to a Java program
People want to do object-oriented, but have no idea what that is. They actually learn fragments of what OOP is and try to apply it. Usually you get a monster and you get the worst of both worlds.…
-
3
votes1
answer2003
viewsA: Loop "for" counted odd number, even and average
To calculate the average need to find the total and this was not being done, was dividing by something meaningless. I also improved some, for example eliminated the vector that was not actually…
-
1
votes1
answer992
viewsA: Check if there is value in the enumeration by the attribute and return its value
The first major change is to make the method generic and not leak abstraction. Another change is that I would put the two methods together in one using tuples avoiding exceptions, changes between…
-
2
votes1
answer146
viewsA: What is the difference between Static::Property, Classname::property, self::property?
We are always talking about static properties there. The self::propriedade is the way to refer to a static property within the class code. It’s like using the this, but it’s for static members, not…
-
9
votes2
answers930
viewsA: Removal of excess whitespace
The function AllTrim() solves most cases. If you want to delete in the middle: Function MiddleTrim(cText) Local cClean := "" Local cLast := " " Local nLen := Len(cText) Local i Local cChar For i :=…
-
3
votes1
answer1477
viewsA: What exactly does the Application.Doevents() method do?
Message is a term that Windows uses. When you program for Windows you kind of are using a framework from it, then the application stays the whole time communicating with the operating system through…
-
7
votes3
answers6315
viewsA: How to make an "Insert" with Dapper using a class?
You need to have properties in class, so change your class to: public class Teste { public int Id { get; set; } public string Nome { get; set; } public int Idade { get; set; } } And change: var…
-
3
votes2
answers1331
viewsA: How to remove the value of the last Textbox position with Substring?
Assuming really only the last %, that nothing has been typed wrong, and usually something can be, a lot can go wrong if it’s not as expected, and validating everything takes work, then this would be…
-
11
votes3
answers1178
viewsA: What is the difference in use between the Matcher() and find() methods?
matches() looking all over the string, that is, the pattern you are looking for should be exactly the same as the string being used to search. It’s like using an equal. find() look for that pattern…
-
2
votes1
answer112
viewsA: Creation of anonymous objects vs "named (?)"
I don’t know how this structure of yours but just create a static utility method in a class that makes sense to return it, something like that: public static StudyLogRepository BuildStudyLog() =>…
-
15
votes3
answers2216
viewsA: How to reverse an integer?
Normally these exercises are to demonstrate the ability to assemble the best algorithm, and not go the easy way, so I would do it mathematically. I took the opportunity to fix the problem that if…
-
2
votes2
answers1476
viewsA: Print components of an array in reverse order
The big problem is you’re declaring array before knowing what is the desired size for it. So first ask how many elements it should have, then declare with the informed size. #include…
-
28
votes1
answer2059
viewsA: What are the coroutines?
Are routines cooperatives, that is, are routines (functions, methods, procedures) that agree to stop its execution allowing another routine to be executed at that time hoping that this secondary…
-
4
votes1
answer361
viewsA: What is protocol-oriented programming?
It is vague because there is no formal definition, it is not universally accepted. Swift is a language that uses protocols to generalize operations, and in the background protocols are interfaces in…
-
2
votes1
answer112
viewsA: About __forceinline and __inline
These instructions indicate to the compiler that you want the function to be linearized, i.e., that instead of calling it its code is placed where it had a call saving a few bytes and processing…
-
3
votes2
answers768
views -
7
votes1
answer812
viewsA: What are the terms RISC and CISC regarding software development?
To very little development. They are different types of architectures. Today this distinction is more nebulous, the same processor ends up having the two forms. It is not even that the executable…
-
6
votes3
answers701
viewsA: What to do when the argument passed in the constructor is invalid?
The analysis is never so simple, everything depends on context, but in general this is it, should throw an exception preventing the object to be built. Not being able to create an object is usually…
-
6
votes2
answers1129
viewsA: When can I use Static in class?
I know the use of methods static should be avoided Why? Silly little rule told by someone? If you have reason to use have no reason not to use. In fact it is preferable by pragmatic programmers…
-
9
votes3
answers663
views -
2
votes1
answer3602
viewsA: Electronic voting systems in Java
I would help more if I had provided more. I restructured all the code because this form is far from ideal. My version is not ideal either, but for an exercise is good: import java.util.*; class Main…
-
4
votes2
answers161
viewsA: Use Contains in an integer C# field with lambda or LINQ
Try: query = query.Where(x => Convert.ToString(x.MeuCampoInteiro).Contains(filter)); If not, use: query = query.Where(x => SqlFunctions.StringConvert(x.MeuCampoInteiro).Contains(filter)); I…
-
11
votes2
answers3744
viewsA: How does the "for" inline command work?
This is basically the same as writing for i in range(0, len(text), key)] groups = groups + [text[i:i + key].ljust(key, "*") Do you know other languages? The range() generates a numerical sequence as…
-
2
votes2
answers2890
views -
10
votes5
answers1530
viewsA: Do programs written in C# depend on the . NET Framework to run?
Today no longer, even if it depends on a Runtime, as essentially every language depends, of course C# requires a Runtime a little heavier because you need to manage memory, threads security and…
-
2
votes2
answers259
viewsA: How to return a vector to another vector in Java?
This? public double[] método(int n) { return new double[n]; } public void método2(int n) { double vet2[] = método(n); } I put in the Github for future reference.…
-
10
votes2
answers1681
viewsA: Suitable type to use with CPF is numerical or character?
The character occupies slightly more, but is correct. CPF is descriptive information that happens to be composed only of digits, one day may not even be like this. You don’t have to do calculations…
-
4
votes2
answers108
viewsA: Why don’t you instantiate the list so it doesn’t accumulate?
I think your interpretation of what the code is is wrong. You’re probably not thinking about how he’s executed, I imagine you think you put words in and magically something happens. Everything that…
-
4
votes2
answers100
views -
13
votes4
answers13368
viewsA: What are files with extension . cpp and . h?
These are C language source files++ (.cpp) and C (h), although everything that can be used in C can be used in C++ as well and some programmers use this extension even in C++. Ideally, for many,…
-
4
votes2
answers985
viewsA: What are the appropriate scenarios for graph-based databases
None :P Of course there is. The point is that it is possible to use the relational database to make graphs since these are at a level above the relational and more and more the main database…
-
4
votes1
answer2575
viewsA: Inheritance with builders
You need to create the derivate class constructors and call the base class constructor. You have a syntax of your own for this. There were a few more mistakes that I corrected. #include…
-
1
votes1
answer48
viewsA: Page in several languages
If it is one or several pages regardless of whether it is in several languages this will be defined by the general architecture of how the site is assembled. It can be multiple pages, it can be a…
-
18
votes3
answers1357
viewsA: Is it wrong to use multiple cases for the same action on the switch?
No, this is perfectly valid and usual if that’s what you want. If all these states must perform the same action it must be so. In general will have better performance than to do the same with if,…
-
13
votes4
answers316
viewsA: Is it bad practice to make this comparison?
As I always repeat, this good or bad practice depends on context. In this case without knowing all the requirements of what you are doing you cannot answer. Both are correct and acceptable. If you…
-
1
votes2
answers1874
viewsA: Where is a PHP session file stored?
On the server, of course, it would make no sense to keep this control on the client, this information is necessary precisely for the application to keep some state between requests.
-
13
votes1
answer275
viewsA: I could not understand very well the encapsulation in the POO
My experience is that most courses talk about object orientation because everyone wants to learn it. And everyone wants to learn because they say it cures cancer. Which is far from the truth. It’s a…
-
3
votes1
answer41
viewsA: Is my database access function secure?
I always respond that security is multidisciplinary and extraordinarily complicated. If you really want security, call an expert. My inference is that the vast majority of websites and applications…
-
6
votes2
answers489
viewsA: Can a regular expression become Assembly?
The question as a whole is very broad, what you can answer is that it is possible yes, anything can be transformed into Assembly. Or machine code that is probably the desired. Of course what you…
-
2
votes2
answers826
viewsA: C Password Validator
The biggest problem is this while that doesn’t make sense. I improved some other things that might give some gain. #include <stdio.h> #include <string.h> #include <ctype.h> int…
-
3
votes2
answers3980
viewsA: "Undefined Reference" error when compiling in C
You need to compile the two codes: gcc -o main main.c incrementar.c If Code::Blocks didn’t put it up itself it probably created the project wrong. It has to be with Project > Add Files.…
-
1
votes1
answer1259
viewsA: How does Camelcase work? Where do I use upper and lower case names?
This is just a naming convention, not necessarily followed, at least in Java and most languages. Some take it so seriously that they don’t have to, that they themselves don’t maintain a pattern.…
-
8
votes1
answer298
views