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
-
152
votes4
answers6835
viewsWhy should I only use a "Return" in each function?
It is common to see the recommendation to use only one return by function/method. But this seems somewhat meaningless and leaves the code more confusing in many cases. See the examples: The way I…
-
128
votes7
answers5450
viewsHow to write easy-to-maintain, readable code?
How to know if the code is easy to read and maintain? I usually abstract a large part of my codes, I have a habit of using a lot lambda functions in C#. As this function for CPF validation. public…
-
108
votes4
answers48488
viewsWhere should I put a Javascript code in an HTML document?
Where Javascript code should be placed in an HTML document: in the element <head> or <body>? At the beginning or end of each one? Is there any difference in performance or any other…
-
106
votes5
answers12967
viewsWhy is the use of GOTO considered bad?
Some languages, such as C, still have the instruction goto. I have always heard that using it is not a good practice. I would like to know: What would be the reasons to avoid the goto and what…
-
100
votes4
answers4254
viewsWhy should we avoid returning error codes?
It is common to say that one should avoid returning error codes in a function when some operation fails. It is not hard to see that error codes are confusing (is it a valid value or an error?) and…
-
90
votes2
answers4577
viewsDRY is to avoid redundancies, right?
The DRY means Don’t Repeat Yourself. So every time I see a repeat in the code I’m not doing DRY? Is DRY about not having redundancies? How it should be applied?…
terminology software-engineering encoding-style programming-principlesasked 8 years, 7 months ago Maniero 444,682 -
69
votes8
answers13920
viewsIs <br> or <br/> or <br />right?
I see each one using a way, I even vary the shape in a few moments and all work, but what is the right one? It depends on HTML version or the browser?
-
66
votes7
answers12436
viewsUse semicolon or not at the end of the lines in Javascript?
I have read some comments on the web about whether or not to use the ; at the end of the lines when writing Javascript. Some say yes, others say no need, but none can explain well the reasons for…
-
65
votes3
answers5311
viewsWhen to use var in C#?
In C#, local variables in the scope of a method can be declared with implicit type using var, and type is solved at compile time: var i = 10; // implicitly typed int i = 10; // explicitly typed…
-
64
votes11
answers8299
viewsShould I write my program in English or Portuguese?
When I am writing programs, I usually write the names of variables in English (for example, fields, class_name, rec_number), for a number of reasons: Names in English don’t have accents, so there’s…
-
60
votes2
answers2892
viewsPHP mixes object-oriented codes and procedural language?
I am learning PHP, and by the example I have seen on the internet there is a mixture in the coding of programs, of object orientation and structured procedures. Is that really common or am I…
-
57
votes5
answers7848
viewsWhat is the difference of string vs string?
I wonder what the real difference is between String (capital letters) and string (s tiny). Apparently the two have the same goals, but which is "best" to use?
-
56
votes2
answers3301
viewsWhat is a paradigm?
What is a paradigm? Is there any more important than another? It’s the same thing Pattern design (design pattern)? It’s the same as language?
terminology encoding-style software-engineering paradigmsasked 8 years, 4 months ago Maniero 444,682 -
54
votes5
answers7178
viewsWhat is the advantage of using recursive functions?
Recently discovered the famous (or not so famous) Recursive Functions and I found the concept very interesting. However, during my reading I had some doubts regarding the use of such. What is the…
php loop software-engineering recursion encoding-styleasked 8 years, 10 months ago João Paulo Vieira da Silva 1,933 -
52
votes4
answers3803
viewsWhat is spaghetti code?
When reading about software architecture on the web, sometimes the term is used "spaghetti code", referring to something that should be avoided. But I could never understand clearly what "spaghetti…
-
48
votes3
answers8111
viewsNomenclature standard in code for C#
I recognize that it is common for each language to use a pattern to compose its identifiers (variables, constants, objects, controls etc). In the case of C#, what would be the best practices…
-
43
votes3
answers8167
viewsWhen to use recursion and when to use loops?
A problem can be solved and get the same result used a loop or through recursive calls to a function. Whereas the programming language being used has both features, how to know when one is better…
function loop software-engineering encoding-style recursionasked 10 years, 5 months ago Maniero 444,682 -
37
votes2
answers2324
viewsWhy do they say using arroba to suppress errors is bad practice?
In PHP, we can suppress errors using arroba before certain expressions. This can be seen in: What is the function of@at the beginning of PHP expressions I already watched some Hangouts on PHP and…
-
36
votes3
answers1858
viewsHow to know the right measure of comments?
I went through PHP, C, C++, Javascript and now I’m working with C#. All this time I’ve always heard that it’s important to have well-commented codes, but I never knew the right measure of comments.…
-
35
votes2
answers1067
viewsIs there a problem using Unicode characters for code identifiers?
Today it is common for compilers of programming languages to allow the code file of their programs to accept code with Unicode characters. This is useful, especially for those who use Portuguese and…
-
33
votes3
answers1026
viewsWhat problems can a global state entail?
What problems can a program face with the use of global states? Where can it be acceptable? That is, how to know if I am abusing the resource? What alternatives exist to avoid this? I’ve already…
-
33
votes1
answer522
viewsDoes the size of a function affect memory performance and consumption?
Does the fact that a function is higher or lower affect the performance of the application? Especially in PHP. If you need performance, it would be better to perform large or small? And memory…
-
33
votes2
answers1168
viewsWhat defines a clean code?
I saw this term being employed several times, many people and companies want their codes to be "clean"... I also saw the book Clean Code Agile Software Practical Skills. But I wanted to know what…
-
31
votes6
answers3667
viewsAre there objective advantages to a language being "case sensitive" or not?
Or is this just taste? I don’t want to if you like one more than the other. I don’t care why people like one or the other. I don’t want any bad answers. I don’t want to know historical reasons. I…
encoding-style language-design case-insensitive cash-sensitivityasked 9 years, 4 months ago Maniero 444,682 -
31
votes1
answer5487
viewsWhat is the difference between single quote ' and double quote " in SQL?
Context When I do an SQL and wish for a specific alias I should quote between double quotes ". SELECT A.ds_nome_pessoa AS "Pessoa.nome" ... When I want to make a where in field varchar the values…
-
30
votes1
answer1075
viewsPolymorphism in procedural language
One of the characteristics of object orientation is polymorphism, the ability of a method to perform different behaviors according to the context that can be defined by a hierarchy…
-
29
votes1
answer1530
viewsProperty Vs variables
I’ve always used properties in C# this way: public int Numero { get; set; } Today I asked myself, why do I use this get and set instead of a variable? Is there a difference? I only use it that way…
-
28
votes6
answers1694
viewsWhy not use a Boolean parameter?
I’ve seen in some places you shouldn’t wear something like this: int teste(object obj, bool especial) { ... } There within the function some operation will be done or not, depending on what you…
function encoding-style software-engineering parameters booleanasked 7 years, 7 months ago Maniero 444,682 -
27
votes6
answers1673
viewsBig job or small job?
Why is creating a large function or method with many lines of code considered a "bad practice"? What are the drawbacks of this? What do I get in dividing into smaller functions or methods? What…
-
27
votes6
answers2483
viewsWhy is Drag-and-Drop programming rarely used?
There are currently several applications Open Source, including Brazilian projects. However, what I realize is that the function of Drag-and-Drop that the IDEs provide. I notice that many projects…
-
26
votes4
answers6194
viewsBest practices for naming functions
I would like to know which tenses are most used to name the functions. For example, there is a more suitable in this hypothetical case? Calculadora calculadora; calculadora.soma(3, 4);…
-
24
votes1
answer933
viewsWhy is the use of "break" considered bad?
In many places I have heard several comments about this, such as: "Professional programmer does not use break" "The code sucks when you see a break" Because the use of break is so frowned upon by…
-
24
votes1
answer678
viewsWhat is data-driven design?
I came across the term data-oriented design, I saw some things and I was a little surprised because what I could see on top is different than what I could imagine, since these terms usually refer to…
terminology performance modeling encoding-style paradigmsasked 7 years, 4 months ago Maniero 444,682 -
23
votes2
answers885
viewsTo what extent should I follow the conventions, where can I apply specific style patterns of my own?
How far should I follow the conventions in Java codes, that is, how far the convention is a rule? I can develop and apply my own styles of coding patterns in my code, knowing that I will use this…
-
21
votes3
answers1556
viewsSQL in the code or in the database?
I’m having a big doubt about where I should put mine query SQL, whether in code or bank. Currently I have a Procedure which is mounted according to the parameters I have, ie, filtros. Procedure…
-
21
votes3
answers866
viewsWhat are "Magic Numbers"?
My IDE informed that I am using magic numbers in my code, in the stretch f = 12. I’d like to know more about "magic numbers". I need to have a variable with a value of 12, but the IDE said something…
encoding-styleasked 8 years, 5 months ago durtto 3,109 -
21
votes4
answers694
viewsWhy not comment on the code?
After reading a bit of Robert C. Martin’s Clean Code, he says that it is no use to "make up" a bad code with comments, in other words, try to explain a gambit made there. It is also quoted about…
terminology characteristic-language encoding-style commentsasked 5 years, 4 months ago CypherPotato 9,292 -
19
votes6
answers2856
viewsCan not use "{ }" IF keys in PHP cause problems?
Usually for checks that modify only one line I have avoided the use of keys, because PHP accepts this method, but I rarely see codes from other programmers like this... Examples My method…
-
19
votes1
answer1697
viewsWhat is Fluent Interface?
I quickly read some articles about Fluent Interface but I could not clearly understand this pattern. Definition Wikipedia: It is an implementation of an API oriented to object that aims to provide…
-
19
votes2
answers787
viewsWhat is elegant coding?
I always see some answers to questions suggesting that if you do something x is more elegant than the y form. I started thinking what would be elegant in our context. 9 pages of 50 records with the…
-
18
votes8
answers2700
viewsIs it good practice to mix Php and Html?
I see that in python, has the Bottle for example that does the same thing of what I intend to do then... I am new to web practices, student indeed and would like to know if I can use php and html in…
-
18
votes2
answers1713
viewsWhat is a scalable code?
Scalability is linked to growth, in the context of code, I have some pertinent doubts. What is a scalable code? The scalability of code involves more than one aspect or only performance or design? A…
terminology software-engineering encoding-style scalabilityasked 5 years, 9 months ago renanvm 3,797 -
17
votes1
answer990
viewsIs using an empty catch a bad practice?
There have been cases where I needed to make use of methods that launched exception if any error occurred, but the exception would stop the execution of script, what would be something unwanted. For…
-
17
votes3
answers4038
viewsWhat is the definition of verbose code? And why is it interesting to reduce it?
I have recently heard about verbose code reduction (next to the term Boiler Plate code), and also by studying ES6 by falling into Arrow-functions. Would you like a clearer definition of what verbose…
javascript terminology encoding-style ecmascript-6asked 7 years, 11 months ago Denis Bernardo 1,770 -
17
votes2
answers319
viewsWhy are the other types of variables not replaced by Dynamic in C#?
I was studying C# and I came across a type of variable dynamic, which, as I understand it, accepts any value I enter. Unlike other variables, for example: If I declare how int, I have to type one…
-
17
votes1
answer5166
viewsWhat are the reasons to choose between camelCase and Pascalcase in method names?
First, I’m not interested in what you like best or what you use in your language, I want to know the motivation to choose one or the other pattern in a hypothetical language. Second, this is a bit…
characteristic-language method encoding-style ux language-designasked 5 years, 6 months ago Maniero 444,682 -
16
votes4
answers4276
viewsShould I initialize strings (or objects in general) with null?
I have noticed that a common practice among programmers is to initialize an attribute of a class with null. Is this good practice or not? Is there a difference between initializing with null or not…
-
16
votes3
answers1076
viewsIs it correct to prefix variable names with their type?
It is usual/correct to use variables where the first letter references their typing? Ex.: string sVariavel; int iVariavel;, etc.... EDIT: The name of it is hungarian notation. Is that good practice?…
-
15
votes4
answers3950
viewsWhen to use ternary condition?
I particularly like the use of ternary condition, but I see many developers saying no, there is even a rule in Checkstyle when validating your code that encourages you not to use. See the example…
condition encoding-style conditional-formattingasked 10 years, 9 months ago Philippe Gioseffi 3,202 -
15
votes4
answers1443
viewsShould an enumeration be constant in the lifetime of the solution?
Modern languages often have a type of enumeration that is usually a range of related constants. Its members are usually constant. In most languages this is even guaranteed by the compiler. But…
software-engineering encoding-style enums constant lifespanasked 10 years, 5 months ago Maniero 444,682