Posts by Maniero • 444,682 points
6,921 posts
-
1
votes1
answer225
viewsA: How do I get a value in Lua without using io.read()?
Ready in the library is that right there. Always have several ways to get the same, but if you want to read from the console is the best way. Example: local stdin = io.stdin:lines() for line in…
-
2
votes1
answer120
viewsA: Generate the primary key in the application or keep it auto-incrementable?
Should I set the primary key of my table as auto_increment or define it as numerical, generating the key within my application? In the database always. 1) With a key of the type auto_increment, to…
-
22
votes1
answer1626
viewsA: What is Flyweight Pattern?
Memory saving He is a form of cache yes, but it’s more for sharing. It is always useful when you need to have multiple instances of an object that have basically the same value. This obviously makes…
pattern-design software-engineering memory-management immutability flyweightanswered Maniero 444,682 -
27
votes2
answers868
viewsA: What is the purpose of alt in a <img /> tag?
It is to put the description of what the image contains. It will be shown in place of the image if it cannot be displayed. Useful for: facilitate content indexing, then serves for SEO, show…
-
8
votes2
answers5592
viewsA: Variable Static and #define
#define actually not even part of the language. It is just a text that before the compilation will be exchanged for a value. It looks like a variable, but it is not. The value will be used.…
-
10
votes1
answer1208
viewsA: Why String objects are immutable?
This will never change, a lot of code has been done with this premise. It could one day have something additional, in a way it already has that is the StringBuilder. In a general way it is not…
-
4
votes1
answer601
viewsA: Return local function variables
You can’t do that. The array is allocated in the stack, when the function ends it can no longer be accessed. The worst is that in C you can even in some circumstances that you have no control over…
-
3
votes3
answers1227
viewsA: Is there a Data Annotation that prevents data duplication in the Database?
There are some forms, the one that is probably the most suitable for you would be to use the attribute Index to create an index in the database and indicate that it must have a unique key. public…
-
4
votes2
answers359
views -
3
votes1
answer282
viewsA: Is there any way to assign values to a vector faster?
Directly you don’t have no. You could create a function where you pass the parameters and it assigns each element. But that’s the opposite of being faster, at most it gets shorter. This generally…
-
1
votes1
answer96
viewsA: How to execute a select within an IF/CASE condition?
You have to select the boolean expression you need. The * is to pick up all columns. The SELECT ***select* the information you need, if it’s a condition, use it there. IF (SELECT (f.Email IS NULL OR…
-
2
votes2
answers131
views -
6
votes3
answers189
viewsA: Is it better to have a kind of exception for each case or a more general exception?
For me none of this would be an exception, at least for what the name indicates. I consider a mechanism abuse throw exception to normal situations that may occur in the code. I would adopt other…
-
4
votes2
answers146
viewsA: Pointer changes address when exiting function
Ideally it is better to allocate in the place you will use, so it is easier to track what you need to release, but if you want to do it anyway the most appropriate is to return the pointer and not…
-
1
votes1
answer769
viewsA: Know how many positions were filled in a vector in C
This code has many errors (some do not stop the code from working, but it is not the right way to do it), I will not try to fix them because I would practically have to rewrite everything. To solve…
-
11
votes1
answer165
viewsA: Like, when and why use "Securestring" in C#?
Someone has worked with this class, it is used in large projects? No, I don’t know a lot of great projects to say. I don’t know if that’s relevant. Either the feature is useful or not, whether it is…
-
5
votes1
answer151
viewsA: Problem with null variable
I will consider that DataContext is the type VMUniversityMembers, if it’s not, that’s the mistake. It seems to be after. The estate ProjectContext does not seem to be being initialized anywhere, it…
-
15
votes2
answers3309
viewsA: What does the term "Consume an API" mean?
It means using it :) It means that your code will access it somehow. It will invoke the available actions to request information, have operations performed. Just write a code that requests it, it’s…
-
12
votes1
answer7625
viewsA: Difference between Triggers and Stored Procedures
Stored Procedures They are like functions to be called by various circumstances. In thesis can do anything, even not related so directly to the tables, although rare. Don’t think there’s anything…
-
4
votes2
answers72
viewsA: Visual Studio 2015 says "this" is redundant
You need to see where you learned OOP. The fact is that almost everything on the Internet teaches wrong. Many books, mainly by national authors, but not only, teach very dirty. But I also don’t rule…
-
2
votes1
answer4794
viewsA: Error: error: class, interface, or Enum expected
One of the main reasons you’re always struggling to understand what’s going on in the code is their lack of organization. Looking at this code really is very difficult to find an error there, even…
-
14
votes2
answers5293
viewsA: What is an Iterator?
It is the mechanism used to "walk", element by element, by a data collection. It is an abstract and generic way of dealing with the advance between the elements of this collection. This advance can…
-
9
votes1
answer13017
viewsA: Tuples in a database
Tupla is a vessel (literal translation) where it places a lot of things. Roughly we refer to it as being the line the table, or the record, as the concept is also known. But let’s be more specific.…
-
6
votes1
answer131
views -
2
votes1
answer92
views -
9
votes2
answers3665
viewsA: What’s a chain list?
A good part is already answered in What is the difference between simply-chained and double-chained list?. So chained list is the same as linked list (Linked list). The functioning of the chained…
-
2
votes3
answers208
viewsA: Repetition of elements
I’ll make a code as simple as it is for a beginner who doesn’t know and can’t do more complex things. In a professional code would be quite different, there would be functions, a proper data…
-
3
votes2
answers175
views -
2
votes2
answers74
viewsA: Vector that generates elements
The main problem of the code is that it is not assigning anything to the vector. I removed what was not being used, organized and modernized the code. #include <stdio.h>…
-
6
votes3
answers11309
viewsA: How to delete duplicate spaces in a string?
Option for those who do not want Regex: var str = "00000.00000 111111111.111111111111 33333333"; while (str.indexOf(' ') != -1) str = str.replace(' ', ' '); console.log(str); I put in the Github for…
-
7
votes2
answers477
viewsA: What types of resources are released in a "using" statement?
No resource is released because you used the command (not to be confused with the name import directive) using. The only thing guaranteed that the using is to call the method Dispose() of an object,…
-
2
votes3
answers582
viewsA: How to dynamically increase struct size?
The size of struct is not possible. What it seems you are wanting is to increase the size of the array. Also not dynamically, created, stays that size. What you can do is allocate heap a sufficient…
-
3
votes1
answer68
viewsA: Variable-sized Object may not be initializad
I did compile declaring the undeclared variables, which was the problem (for me that is a mistake. Maybe the question is not even clear. I gave a good overall improvement, but the code still has…
-
8
votes1
answer4477
viewsA: What does Traceback mean?
Is the same as stacktrace, a somewhat more commonly used term in general languages. Literal translation is tracking. So it serves to track what the application is doing, but in a simple way. The…
-
7
votes3
answers1511
viewsA: How can I replace a part of a string by itself plus the "~" character?
The question cites Regex and the accepted answer gave a good solution. I prefer to do it manually because I make it easier than I would with Regex, but I know that’s not the case with everyone. If…
-
6
votes1
answer97
viewsA: Strange values in output when running newly compiled application
The code has several problems. Some are organizing and I haven’t solved them all. I wouldn’t use this function acessa, at least this way is not useful, it may be later changed to be more useful.…
-
6
votes2
answers2900
viewsA: Customize Messagebox in C#
This is not possible, it was created to do something very strict even. This is a case where you need to create your own component. Not to leave without any reference has something ready in…
-
15
votes1
answer2100
viewsA: Difference between Std::list, Std::vector and Std:array
std::array It has semantics equal to array normal C, but it’s a better way to use C++ when you need a sequence of contiguous, fixed-size objects. Obviously it does not decay to pointer as with the…
-
2
votes2
answers1291
viewsA: What is READ_COMMITTED_SNAPSHOT?
This is a SQL Server configuration. It determines that everything that occurs in the current transaction will consider the values that exist at the beginning of it. Any change to any data made by…
-
6
votes3
answers1743
viewsA: Transform Number into binary text
If you want it to work in a generic way, including negatives: function dec2bin(dec) { return dec >= 0 ? dec.toString(2) : (~dec).toString(2); } console.log(dec2bin(47));…
-
2
votes2
answers1191
views -
9
votes2
answers312
viewsA: Who is who in the use of functions?
function funcao(parametro) { var variavel = 1; return parametro + variavel * 2; } var x = 4; console.log(funcao(x + 3)); I did it in JS just because it’s the easiest one around here. It applies to…
-
6
votes3
answers1653
viewsA: Picking up part of the phone
The easiest thing for me is to make one simple SubString(): using static System.Console; public class Program { public static void Main() { var fone = "(12)34567-8901"; WriteLine(fone.Substring(1,…
-
20
votes4
answers4174
viewsA: What is the meaning of the operator ( * ) asterisk?
Just like C, this operator is used for multiplication. It can even be used to multiply a string by a number. In C the symbol is also used as an operator to pick up the value indicated by a pointer…
-
4
votes2
answers988
viewsA: Declare public variables in the __Construct method
Visibility The decision whether to leave the public variable or not is the programmer according to the need. The fact that it is not used elsewhere does not mean that it cannot be used at some…
-
4
votes2
answers65
viewsA: How to call a function that prints the name of the calling function?
Can do that: function imprimir() { console.log('Funcão que chamou: ', arguments.callee.caller.name) } function criarEvento() { imprimir(); //os argumentos são irrelevantes para o problema }…
-
2
votes3
answers1521
viewsA: How to Put Music on Console Aplication with C#
The question does not give details, but the basics would be more or less this: var player = new SoundPlayer("NomeDoArquivo.wav"); player.Play(); I put in the Github for future reference.…
-
3
votes7
answers2833
viewsA: How to check if at least one item of the array has value equal to or greater than 2
In the series of questions the AP is asking ([1], [2]), Much alike, I will insist on simplicity, performance and even legibility, although the latter is a subjective way of evaluating. I would do…
-
8
votes5
answers7032
viewsA: How to return the sum of numbers of an array with indices of value greater than or equal to 2
I still prefer the good old manual loop (much faster, readable and simple): function Somar(array) { var total = 0; for (var i = 0; i < array.length; i++) { if (array[i] >= 2) { total +=…
-
13
votes2
answers283
viewsA: What is the difference between using a comparison with >= or simply >?
Comparing by greater or equal can have a cost in processor cycles greater than just comparing with greater. As long as this operation is actually done. Understand that it is common that in machine…