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
-
7
votes2
answers461
viewsWriting conventions for ASP.NET controls
When you drag a control from Toolbox to a Web Form Visual Studio automatically adds an ID to this control consisting of its type with uppercase first letter and a number. This is the same pattern…
-
7
votes4
answers714
viewsTrying to condense conditional with three possibilities
The problem is to present a result flexing to the plural if necessary, or "no": Let ni>=0 (number of items): switch(true){ case $ni==0: $html = ' (nenhum)'; break; case $ni==1: $html = ' (1…
-
7
votes3
answers254
viewsWhy validate even with a default value
When I’m preparing something, however simple it may be, the question always arises: I must trust the mine code? This puzzle is usually associated with the fact that "tomorrow" may not be me…
php exception validation software-engineering encoding-styleasked 10 years, 3 months ago Zuul 35,190 -
7
votes3
answers187
viewsOmitting Else is a good idea in some cases, right?
I ask myself this question every time I’m coding, because I always worry about leaving my code understandable to other programmers who will contemplate it - and myself, because maybe I won’t…
-
7
votes1
answer105
viewsIs there an alternative to multiple while loops?
I have a method alterar() that change the data of a particular element of my XML Person, however, this routine uses several whiles one for each element, see below the routine: public void alterar()…
-
7
votes3
answers590
viewsNever use inline styles is never really?
For example the tag canvas: I saw some tutorials on Youtube, and almost all of them used it like this: <canvas height="" width=""></canvas>. Then I should use it in HTML, inline, as…
-
7
votes3
answers701
viewsWhat to do when the argument passed in the constructor is invalid?
I’m playing a card game in Java, and one of the classes is responsible for starting the game. In the builder, I get the number of players who will participate. I am doing the validation of the…
-
7
votes3
answers1500
viewsWhen to use blank lines in a Python program?
Skipping lines is one of the aspects that make a program well indented? If so, what is the criteria used to skip lines?
-
7
votes2
answers351
viewsReadability of javascript codes
When writing a code you must do it so that the time required for your understanding is minimal. This is the most important metric to have a readable code and is the foundation of the fundamental…
-
7
votes1
answer201
viewsMeaning of "code acting on data" and "data controlling access to code"
This is a purely theoretical question about programming. I would like to know from an example simple (response with complement of figures, drawings, etc.), the meaning of two sentences for two types…
oop terminology software-engineering encoding-style structured-programmingasked 6 years, 4 months ago neves 5,644 -
7
votes2
answers283
viewsUse of empty "print()" in place of " n" before conditions
Have a problem using print() before conditions instead of using \n. For example let’s say I have something basic like: `idade = int(input('Quantos anos você tem?')) if idade > 0 and idade <…
-
6
votes1
answer213
viewsHow to implement 'check in' in tfs 2012 only approved by the reviewer?
I would like to know if it is possible and how do I stop the Check In so that only the reviewer can upload the code, or that it is not possible without your permission. To ensure that cases in which…
visual-studio-2012 encoding-style team-foundation-serverasked 11 years, 1 month ago Raoni Zacaron 325 -
6
votes3
answers301
viewsWhat is the advantage of using include de array vs configuration file?
I have observed some codes where the programmer does the following: /** Arquivo A.php */ return array('databaseName' => 'bancoTeste', 'port' => 5208); /** Arquivo B.php */ $configs =…
-
6
votes0
answers281
viewsWhat’s a noodle code?
Sometimes I see some programmers using this term. Is macaroni code a bad or messy code? I don’t know if he has any relationship with spaghetti code. What is the meaning of these terms ?…
-
6
votes3
answers101
viewsIs there any justification for this change? Change in variable pattern
A coworker read on a forum that using shorts, int and long was the right and best way for the system’s performance, so it began to change on all screens and classes it worked on. I searched and saw…
-
6
votes2
answers379
viewsIs it bad practice to overwrite declared variables as a function parameter?
I used to get "reassigned" a value of a certain variable that was declared as nome of the function parameter. Example: function format($string) { $string = ltrim(rtrim($string, ']'), '['); // A…
-
6
votes1
answer775
viewsMandatory field rule should be on the backend or frontend?
I’m building an application where the backend is an API and the frontend is Angular2. In a user’s registration I do a validation in the API and if a required field is not filled in the API returns…
api validation encoding-style software-engineering angularasked 8 years, 3 months ago Diego Zanardo 3,301 -
6
votes1
answer90
viewsHow is it correct to declare a variable that is a pointer?
I see some people do int* variavel; And some people do int *variavel; What is right?
-
6
votes1
answer4920
viewsIs there a difference between using "Return" or "Exit()" to terminate the "main()" function?
The function exit() closes the execution of the application immediately. The command return makes you quit the function, but when you’re inside the main() will exit the application, including the…
-
6
votes1
answer112
viewsTables with unconventional names like ABC1234
I have seen some that some systems adopt a different way of naming tables with letters and numbers like ABC1234, XX_900, etc.. These days I’ve been working on creating some queries in a system that…
-
6
votes1
answer76
viewsDynamic typing and team development
Is there any good practice, standardization, recommendation, etc. aimed at preventing invalid types from being passed to methods and functions? If I am working alone is more quiet, I even wrote the…
python python-3.x software-engineering encoding-styleasked 6 years, 9 months ago Matheus Saraiva 2,157 -
6
votes1
answer85
viewsShould I avoid operations between constants in a loop?
In C++ there is some sort of optimization or cache that prevents the same mathematical operation between constants to be repeated, mainly in loops, thus decreasing application performance? For…
-
6
votes2
answers454
viewsHow to write acronyms in camelCase?
How should I treat acronyms in camelCase? should I leave them fully uppercase or just the first letter? What would the variable look like algumaCoisaSiglaAleatoria? Or algumaCoisaSIGLAAleatoria?…
-
6
votes1
answer292
viewsShould we create an empty constructor in Java?
It is good practice to always declare a builder, even if it is empty, for the class? I find it unnecessary, because the compiler automatically creates. I have seen people who always create and…
-
6
votes1
answer107
viewsWhat are the advantages and disadvantages of encapsulated errors types like "Result"?
I’m learning Rust and one of the things that made me curious is the absence of exceptions. Unlike languages such as C#, Java, Javascript, etc., which have exceptions, in Rust this does not exist. If…
-
5
votes1
answer986
viewsIs loading PHP into JS a good practice?
I see quite often in some questions here Sopt some codes that have PHP variables within scripts in JS. Let’s assume the file below is index.php. <?php $var = "Me mostre"; ?> <script>…
-
5
votes1
answer306
viewsDoes programming in English conflict with the construction of a ubiquitous language?
I have already found on the internet some arguments in favor of programming in English, instead of programming in Portuguese, and we even have a question questioning what would be the recommended…
-
5
votes1
answer346
viewsWhen should I instantiate a class?
I’m having second thoughts about the best time to call for instantiate a classe. Should I do it at the beginning, before the builder, at the constructor or at the time when we will make use of some…
-
5
votes1
answer110
viewsAllow new conditions to be added without modifying code
I am manipulating a .txt and I have to exchange values like M31 for T90 for example. My code is like this at the moment: //Change machine tools for Sodick if (_strLinesFinal.Contains("M50")) { _OS =…
-
5
votes1
answer64
viewsIs it wrong to have header and Section tags and not have a footer?
I have a single page application, very simple even, and used the tags header and section, without creating a footer, because I found it unnecessary. Is there a rule or recommendation about this? Can…
-
5
votes1
answer557
viewsIs it recommended to manipulate rules with "Try-catch"?
We can manipulate errors in various ways, but the one that will use less code and time of the programmer is the try, present in almost all object-oriented languages. But, when should be used try,…
-
5
votes3
answers349
viewsWhat are the advantages of using PHP’s sprintf function?
I can see an advantage in using the function sprintf in place of concatenation: readability. In addition to readability, what are the other advantages of sprintf() in relation to concatenation? Is…
-
5
votes1
answer112
viewsIs it prudent to use several paradigms in a C++ project?
Would it be advantageous to use several paradigms in a project in C++? For example, in a certain part of the code I use reactive Programming, in other parts I use OOP, and in other parts I use…
c++ oop encoding-style functional-programming paradigmsasked 6 years, 3 months ago Strawberry Swing 177 -
5
votes4
answers146
viewsPerforming functions with and without creating local variables
Despite the simplicity of this question, I could not find an answer to it on the Internet. Is there any structural/performance difference between the two functions defined below? def F(x): Output =…
-
5
votes2
answers1797
viewsIs there any way to decrease the amount of Else and if?
I should create the conditions for enrolling students based on their age, I was wondering if there is any way to decrease the amount of if in that part of the code: int idade =…
-
5
votes2
answers355
viewsWould using underline in C# be good practice?
The question refers to development pattern and good practices. I come from a Javascript and PHP world, work for 12 years with development, and I’m very used to using underlines _ variables, such as…
-
5
votes1
answer104
viewsIs it recommended to explain all variables?
This is a question as to the readability of the code or if there is any style pattern as to this. Well, the Zen of Python tells us that Explicit is Better than implicit. but how to interpret this?…
-
4
votes2
answers272
viewsHow to create a box with two separate texts
Hello, I am a beginner of XHTML and I ask you to tell me about this code and not Html5. I want to make a header but I’m not getting it. The goal is for the first text to be higher than the first.…
-
4
votes1
answer282
viewsIs sending parameters to another function using object or hash a good practice?
Exemplo: function atualizar(dados, events) { //faz qualquer tratamento dos valores var hash = { novoValor: dados, outroValor: event }; // primeira opção return customize(dados, event); // segunda…
-
4
votes1
answer415
viewsStatic public variables in C#
How can I organize my code? When programming there are variables that I am leaving in the same code at the top as: namespace myData.MySql { public partial class teste { public static string…
-
4
votes1
answer49
viewsWhat is the best way to perform a dependent addition/subtraction operation?
It is common when one is at the beginning to come across this doubt. I have to perform an operation that is dependent on a condition : Example 1 $operacao = 'somar'; $valor1 = 5; $valor2 = 10;…
-
4
votes1
answer240
viewsWhy are there so many parentheses in macro?
Seeing this, it intrigues because it needs those parentheses that seem unnecessary. What is their functionality? #define SUB(x, y) ((x) * (y))
-
4
votes2
answers72
viewsVisual Studio 2015 says "this" is redundant
In the early days of my first object orientation classes I was taught to use the thiswhere it is a variable or class property. Today I understand when there is a real need to use, for example when a…
-
4
votes2
answers417
viewsIs using HTML5 tags as CSS3 switches a good practice?
Use the names of tags HTML5 as most CSS selectors is a good practice? Be it because I’m not creative to give names to ids or classes, or by wanting to make HTML code as clean as possible, leaving…
-
4
votes1
answer1480
viewsAfter all, why use C when programming in C++?
I’m learning C++ and I can’t understand why people think C knows C++? Or are the differences between the two despicable? I know the syntax is similar, but C++14 does things that C doesn’t, and aside…
-
4
votes4
answers880
viewsWhy is it not advisable to use PHP codes in the same HTML document?
I was in the lab today showing a simple PHP code example to a colleague and my teacher saw it and asked "Why are you putting PHP together with HTML?". Even without understanding much I answered that…
-
4
votes1
answer125
viewsIs it correct to use PHP code in the view layer along with HTML?
I’m starting now in the area and I have a college job to do and it is necessary to use the MVC standard, I have even separated things well, but I came across the following code in a file of my layer…
-
4
votes4
answers1933
viewsHow to choose a convention for variable and function names?
I am going through the second development company and in both have no own convention to use in the declarations, in the codes caught functions declared as follows: PHP and jQuery function…
-
4
votes3
answers124
viewsHow can I use or name constants for response type fields?
There are situations in which we have fields that represent a type of response, whether boolean responses sim and não, S and N or with multiple responses like the status of something. For example…
-
4
votes1
answer247
viewsSonarlint, complexity of the "equals() method"
Sonarlint for Eclipse, accuses error: Refactor this method to reduce its Cognitive Complexity from 64 to the 15 allowed. Rewrite this method to reduce your cognitive complexity of 64 for 15 allowed…