Most voted "encoding-style" questions
Encoding style is a set of rules or guidelines used when coding a computer program. Typically, following a certain coding style makes it easier for other programmers to read and understand the source code.
Learn more…234 questions
Sort by count of
-
4
votes1
answer110
viewsTo what extent do you use frameworks?
In general, to what extent and when we should use frameworks? It is important to previously learn "raw" language, or you can start learning through frameworks? What are the disadvantages of using…
-
4
votes3
answers1163
viewsHow to separate HTML from PHP
I read in several places that you should not mix PHP with HTML and vice versa, How then could I separate this code for example: <?php include 'C:\xampp\htdocs\trabweb\sessaoBD.php' ?>…
-
4
votes2
answers346
viewsReuse of variables
I had a question about code optimization. I assume that the more the code is dried, the faster the algorithm will be compiled and executed. Starting from this principle, I have the habit of reusing…
-
4
votes1
answer147
viewsInjection of dependencies into functions and not classes. Is it "wrong"?
It is not new that the concept of dependency injection is almost directly related to classes. Tell me "dependency injection" and I can imagine the following: // services/UserService.ts export…
typescript pattern-design encoding-style dependency-injection iocasked 5 years, 4 months ago Luiz Felipe 32,886 -
4
votes1
answer63
viewsWhat is the code convention name for variables that use _?
If variables declared as such: var camelCase = ""; follow the pattern camelCase, what is the default name for variables that use the _, as below? ruby_var = "a questão vale 10 pontos =)"…
-
4
votes1
answer44
viewsHeap things on a function x DRY
That bold bit taken from here it wasn’t very clear to me: DRY solves what? Some may still be thinking that DRY is to reduce typing. Or at least gain maintenance time. It’s even in the latter case,…
-
3
votes2
answers117
viewsUse multiple names with distinct functions in a variable
See these variable statements: var level = 0; var atual_sequence = 0; I could put them together like this?: var level, atual_sequence = 0; One would affect the functionality of the other?…
-
3
votes1
answer79
viewsHow to organize arrays
In the documentation of Pear, it sets a pattern for how to mount the structure of an array: $some_array = array( 'foo' => 'bar', 'spam' => 'ham', ); This way, which I already use, separates in…
-
3
votes1
answer518
viewsDesign structure
I have a project being developed with VRaptor and I have a question about the structure of project. The project I’m developing will be installed in several clients, each with a different structure.…
-
3
votes1
answer124
viewsDeclare variables at or near the top of where they are used?
Is it better to declare all the variables right at the beginning of the file, even if they only come to be used, I don’t know, a thousand lines later? Or better go declaring as the program evolves?…
-
3
votes1
answer240
viewsHow is a scope block identified in a language like Python?
How a language identifies a block where it does not use keys to open and close? function exemplo(){ // ... } I believe that in the example above the parser create a scope block from the keys, but in…
-
3
votes1
answer83
viewsWhy use "is" at variable start in Kotlin?
What is the reason for using the is in front of the variable. Example source code. I know it has something to do with the set. class Rectangle( val height: Int, val width:Int) { val IsSquare:…
-
3
votes1
answer247
viewsShow codes for user
Hello! I have one forum and, in publications of my users, they can add codes to display them using the bbcode tag [code][/code]. I’d like to know how to make stylize the code, as it happens here in…
-
3
votes2
answers1752
viewsIs it possible to evaluate a ternary expression with 3 possible values?
Let’s say I have this account: var total = valor1 / valor2; The result could be three possible values, like: total > 5 total > 0 and total < 5 a positive value Note: They are percentage…
-
3
votes0
answers47
viewsStrange expressions in PHP
Someone explains why this: <?php $world = _("World"); $str = <<<EOF <p>Hello</p> <p>$world</p> EOF; echo $str; ?> generates this: Hello World error-free? what…
php characteristic-language encoding-style syntax certifiedasked 6 years, 9 months ago Julio Henrique 4,352 -
3
votes2
answers268
viewsOpen and close the code or use variable?
Two scripts with the same result: Example 1: <?php ...códigos PHP acima... $tabela = '<table>'; $tabela .= '<tr>'; $tabela .= '<th> Valor1 </th>'; $tabela .= '<th>…
-
3
votes1
answer136
viewsRefactoring Sonarqube code
What could I do to improve this code? Sonarqube indicates that I should refactor this code, but does not present any suggestions: var dados = Set.Where(s => s.Id > 0); if (filtro.IdSolicitacao…
-
3
votes3
answers274
viewsPlacing two functions within one
I made a function that by clicking the button it changes the color of the text and background of a div However, I had to do two lines of command. Is there any way to do everything in one line?…
-
3
votes2
answers293
viewsHow to make a switch in C#?
I see a lot of people saying it’s wrong to do switch in the code, because it ends up weighing and is ugly. Is it correct the way I am using and what would be an alternative to using it? Fill the…
-
3
votes3
answers243
viewsUse of functions in Python
I know that it is possible to create functions in the Python to perform certain tasks that normally need to be performed several times within an application. Ex: Paint shop program that calculates…
-
3
votes2
answers113
viewsIs there any difference between the two ways of making an exception?
Between the two formats below, the throw can be summed up, or create a new object, when casting exception, I just wanted to understand what the real meaning of writing this in different ways, has…
-
3
votes1
answer58
viewsIs it recommended to use typedef in C++?
I know C++ is compatible with C, but C++ has its own way of programming and C as well, so there are legacy things from C that shouldn’t be used in C++, the typedef is one of them? If yes, what to…
-
2
votes1
answer81
viewsDoubt with dynamic layouts
I usually mount the views of the php applications I use with conditional operators. For example, not logged in user, Seto an initial variable in the session: $logado = FALSE; If the user is logged…
-
2
votes1
answer101
viewsWhy define a constant for the same document and check if it exists in the document itself?
I see in many codes out there programmers that setam a constant and in the document itself check whether this constant exists (was defined) in itself. I would like to know why this happens. When we…
-
2
votes1
answer508
viewsPOO using Django
I’m starting to work with Django, but I’m having some doubts about how to organize my project, I would like to know the best way to structure my projects. I’m used to the languages in which I model…
-
2
votes1
answer576
viewsIn an MVC project, where should I leave the enums?
I am developing a program with MVC standard, I needed to create some enum, and left them in the layer Model, but I was in doubt about its location, which would be the most correct layer to house the…
-
2
votes1
answer530
viewsAlternative to If/Else
I have the following code: private void maskedTextBoxEAN_Leave(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(maskedTextBoxEAN.Text)) if…
-
2
votes0
answers77
viewsProgramming standards with safety and simplicity
Maybe this question sounds broad but deep down it is not, I am not graduated in anything so I only have bad practices on my back and wanted to learn to program in a way not only "standard" and yes…
-
2
votes2
answers3199
viewsWhat is the convention for using upper and lower case names in Java?
I once read somewhere about the best practices of using upper and lower case when you name the methods, attributes, variables... in Java, someone could refresh my memory?
-
2
votes1
answer72
viewsReset a variable, or recreate it?
In terms of performance, what is more preferable? There are other differences between the two modes than performance? Reset a variable multiple times? Private Sub Metodo() Dim MeuTipo As Tipo For i…
-
2
votes1
answer53
viewsIn terms of performance, what is the best way to declare a variable that will be used in multiple Actions/Methods in a class?
Which mode is best performatically speaking? Which way you recommend and why? //Modo 1 MeuManager mm = new MeuManager(); JsonResponse MetodoDOIS(string urlImagem) { var abc = mm.Lista(); }…
-
2
votes1
answer171
viewsHow to organize namespaces?
I heard that namespaces should be organized by layer, in case using some Pattern design which makes it possible, as Projeto.Controller, Projeto.UI, Projeto.Model, however, if we look at the…
-
2
votes1
answer75
viewsWhat is the most effective way to develop an Html5 or js code?
For example when I want to do an event at the click of the button I can do it in two ways: using the onclick attribute of Html5 <button type='button' onclick='myFunction()'…
-
2
votes1
answer48
viewsAre there problems using special characters in Python codes?
Thinking of leaving the codes more sleek and sleek would it be possible to use special characters in the codes? It would bring some problem?
python character-encoding encoding-style source-codeasked 5 years, 11 months ago Raul Nascimento 103 -
2
votes2
answers60
viewsDo I need to omit the word "window" when calling a function of the global object?
Following good practice, leaving code readable to other devs, which I should adopt when I call object methods window? Omit or not? Some examples (simple and isolated): const buttonStyles =…
-
2
votes1
answer256
viewsInstantiating an object in the same constructor class is "inelegant"?
It is always seen as a good practice of programming if we create a class for the object, where we have the constructor and make the methods and another class where we instantiate several objects of…
-
2
votes1
answer95
viewsC++ language standard for pointer
I’m starting studies on C++ would like what is the language recommendation (market standard) to reference a pointer. ex: l->propriedade; or (*l).propriedade; I believe there’s no difference in…
-
2
votes1
answer159
views"if" elegant in PHP
(!file_exists($pathFize) ? $response = false : $response = true); if ($response == true) { //executa o código ok } I would like suggestions on how to do this more elegantly, remembering that all…
-
2
votes2
answers74
viewsDifferences of boolean return
I came across the following example: $umidade = 91; $vai_chover = ($umidade > 90); if ($vai_chover) { echo "vai chover"; } To $vai_chover returns a boolean in if, but I found too much code to do…
-
2
votes1
answer164
viewsIn what order to dispose the methods of a Java class?
In which order to dispose the methods of a Java class? Whereas a class can have: constructors, static methods, private methods, public methods, abstract methods. For example: public class Classe {…
-
2
votes1
answer102
viewsShould I specify the type of return of a procedure in Python?
For some time I have studied and learned a little more about Python. I recently read an article about the description of python typing using the module typying. Since I learned about this feature I…
-
1
votes1
answer203
viewsWhat should be returned in the Wndproc function in C++?
Hello. See the code below: LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (message == WM_CREATE) { return(?); } else if (message == WM_COMMAND) { return(?); }…
-
1
votes1
answer51
viewsConventions of when to use _ or $ in Java identifiers?
When to use _ or $ in identifiers? That is, in which cases should I use _ or $ to make my code more organized. For example, I should use $ in front of variable names when building a framework?…
-
1
votes3
answers527
viewsDo I need to use "Convert.Toint32()" for text?
I think it’s something with the Convert.ToInt32(), because I didn’t understand its function inside the language. Observation 1: The place where I learn is American and I don’t know much English.…
-
1
votes1
answer148
viewsUse database data for authentication
I have a database with existing data, with name, CPF, RG and other personal data. I need to implement a login system, but I wanted the user to be in case the registration number and password CPF,…
-
1
votes2
answers106
viewsHow to be less repetitive in my Javascript codes?
This my code looks big and clumsy, is there any way to make it smaller? Something like "easier to write", or smaller? Here’s my example, as you can see, I need to repeat this block 5 times, to…
-
1
votes1
answer284
viewsIn this case use switch or if?
I have an exercise to do which consists of the following: The user informs the salary, and depending on the amount informed, he earns an increase according to the table. Example: From 1000 to 1500…
-
1
votes3
answers73
viewsHow to debug code with Object Initializer format
Following some good practices that Visual Studio itself recommends, we cannot debug values of an object one by one using the "Object Initializer" or "Object Initializer". How best to get around this…
-
1
votes1
answer1259
viewsHow does Camelcase work? Where do I use upper and lower case names?
I didn’t quite understand the concept of naming with uppercase and minuscule letters. I know which classes should be named with the first capital letters (Camelcase), but and objects, variables, and…
-
1
votes1
answer218
viewsIs this a scam?
I’m starting in programming, I have some difficulty reading codes even my own after a while. I was a researcher on legibility and came across the term "gambiarra". this raised a question for me.…