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
-
15
votes8
answers1094
viewsIs it recommended to use constants for configuring a PHP project?
It is very common to see constants in a configuration file in a PHP project, but I would like to know if this is really the best practice, because I think if I store the password of a database in a…
-
15
votes2
answers7197
viewsAdvantages of using Object-Oriented PHP? Where to use?
Lately I did a mini social media and practically did not use object orientation, except for one class I did for CRUD with PDO and ready-made Github libraries. Would this concept be applied more to…
-
15
votes2
answers221
viewsFull snippets of commented codes. Why?
I’m learning PHP and use scripts ready to study them, as a complement. However what I often see is whole snippets of commented code. Does anyone know why? Does it have any function? If the project…
-
15
votes3
answers361
viewsIs it correct to call a method, and pass your null parameters?
For example, I have the event of click of a button calling the method below: //Evento this.serviçoToolStripMenuItem1.Click += new System.EventHandler(this.Nivel_Serv_Click); //Metodo private void…
-
15
votes4
answers314
viewsHow do I know if I am programing procedurally in object orientation?
How to know if I am programming in a procedural style in an object-oriented language?
oop encoding-style software-project structured-programmingasked 7 years, 4 months ago Piovezan 15,850 -
15
votes3
answers289
viewsCondition Yoda, good reason to use?
Question mainly in PHP, in the Wordpress documentation exists an excerpt which explicitly speaks that it is interesting to use the famous Yoda conditions, although it does not give a good and real…
encoding-styleasked 7 years, 9 months ago MarceloBoni 6,385 -
15
votes1
answer201
viewsDoes creating many static classes impact system performance?
I’ve been creating many static classes to facilitate and clear code, such as a Google Translate API call. public static class GoogleTranslate { public static string Translate(string word){ //código…
-
15
votes1
answer346
viewsWhat is the alternative of 'And' in Portuguese for variable names and methods?
One question that always bothers me when I’m in a Java project where we use Portuguese terms is dealing with method names or variables that represent, somehow, two things and I need to mention both…
-
15
votes1
answer605
viewsQuestions about analysis and structured and object-oriented design
Software process, involves various activities, among them, analysis and design. Among the options of methods to perform these activities, we have the structured and object-oriented. Regarding both,…
oop modeling software-engineering encoding-style structured-programmingasked 5 years, 8 months ago renanvm 3,797 -
14
votes2
answers306
views#Region is an antipattern or a Smell code?
The #region from Visual Studio he hides the codes, everyone says he’s bad, because he exists? It’s a antipattern or a code Smell?
-
14
votes2
answers625
viewsIs it really necessary to use mutator and access (Setter and getter) methods in PHP? What about performance?
I’ve been noticing that most other libraries use the methods setters and getters (hereinafter referred to as mutator and accessor), to change the property of some classes. For example: class User {…
php performance pattern-design encoding-style getters-settersasked 8 years, 10 months ago Wallace Maxters 102,340 -
14
votes3
answers2102
viewsWhat is the difference between function and array assignment?
I have recently been coding in my projects where I need to add items in an array, so I don’t know if I should use native language functions for this, for example: array_push($meu_array, 50); or if I…
-
13
votes2
answers1081
viewsWhat are the advantages and disadvantages of Duck Typing?
Duck Typing is a principle that states that one should not use inheritance or interface to define which methods a class should have. Example: # ruim class Animal # método abstrato def speak end end…
encoding-styleasked 10 years, 3 months ago user7261 -
13
votes3
answers1482
viewsWhy does Visual Studio suggest simplifying names? - IDE0001 Name can be simplified
Visual Studio 2013 suggests name simplifications, as you can see below: The suggestion is: IDE0001 Name can be simplified Translation : IDE0001 Name can be simplicate Example: var obj = new…
c# string visual-studio-2013 visual-studio encoding-styleasked 9 years, 3 months ago Guilherme de Jesus Santos 6,566 -
13
votes2
answers995
viewsPHP 7 has argument typing and return, but is it optional. Is that good or bad?
I would not like to raise here a controversial issue regarding the PHP 7 language, which was released recently, but only understand a few points regarding typing. Come on: In versions prior to PHP…
-
13
votes4
answers542
viewsIs there a design standard or recommendation that defines the optimal amount of parameters a function should have?
I always value writing my codes in a short and readable way. My motto is always to think that "someday someone will mess with my code and I want the person who does it to understand it easily".…
function encoding-style parameters language-independent argumentasked 6 years, 4 months ago Wallace Maxters 102,340 -
13
votes1
answer816
viewsHow to make an excellent C++ program without C traces?
As a beginner in C++ I asked some questions here and was warned a few times by @Maniero that what I was doing was C and not C++. The problem is that C++ allows us to use many things similar to C. So…
-
12
votes1
answer2664
viewsWhat are the characteristics of structured programming?
I would like to know what are the characteristics that define the paradigm of structured programming, and what is the difference of this paradigm with the paradigm of procedural programming? Both…
-
12
votes1
answer479
viewsIs inheritance a bad practice for all languages?
I took a course in architecture of Java projects and the instructor told me that heritage in Java is considered a bad practice, which should always be avoided and is preferable if possible to use…
oop software-engineering encoding-style inheritanceasked 7 years, 11 months ago Fernando Bittencourt 174 -
12
votes3
answers329
viewsWhat are "code units"?
I want to know what units of code mean? I saw that term in a reply here at Sopt and I was in doubt. Code units shall be short and have only one responsibility. Link to the question I saw the term…
-
12
votes3
answers1357
viewsIs it wrong to use multiple cases for the same action on the switch?
It’s wrong to do that with the switch? I programmed like this with him, it’s wrong? switch(estado){ case "AL": case "BA": case "CE": case "MA": case "PB": case "PE": case "PI": case "RN": case "SE":…
-
12
votes3
answers2531
viewsHow to select all columns except one in particular?
There is the possibility to select all columns of a table: SELECT * FROM wp_rw_programacao WHERE id = $id But I need to eliminate the result of the column id. It is possible?…
-
12
votes4
answers316
viewsIs it bad practice to make this comparison?
To compare two values with a single one, I can do as in the example: if(foo == "abc" || foo == "54") { ... } But as I need to add more conditions, it starts to get complicated: if(foo == "abc" ||…
-
12
votes1
answer202
viewsWhat are WET Comments?
What are W.E.T., Python comments? Why are they bad?
-
11
votes6
answers57963
viewsHow to convert UTF-8 characters in PHP
In my web application, I am using a Mysql database that has the table EditableContent. This table has the field content, who’s kind text and has as input format utf8-bin. In the database the…
-
11
votes10
answers360
viewsOrganization of CSS
Is there a pattern for organizing CSS? For example: .teste{font-family:"arial";font-size:18px;color:white} or .teste{ font-family:"arial"; font-size:18px; color:white } Which is the most…
-
11
votes7
answers811
viewsHow to write variables in PHP?
I was watching the videos of Robson V.Leite and I realized that at a given moment he retrieves information from the forms to enter into the database in a different way than I use, the only way I…
-
11
votes3
answers1771
viewsCode comments when working in a group
When working in a group, developing code with other people, using specific tools and everything, what is the best way to comment on the code? Well, let’s go to the stage. By owning the project in…
-
11
votes3
answers1792
viewsIs it a good idea to declare variables with accents?
I was taking a look at the PHP Handbook on the variables. There I found an excerpt of code that left me with the "foot behind". $täyte = 'mansikka'; // válido; 'ä' é um caracter ASCII (extendido)…
-
10
votes4
answers58562
viewsCss comments with // instead of /* */
Place // at the beginning of a line creates an invalid property, i.e., CSS ignores that line. div { background-color: cyan; // background-color: red; } I know the CSS standard is using /* */, but…
-
10
votes1
answer400
viewsIs it good to use global variables for greater readability in the code?
I am implementing an exercise of the Deitel book, How to Program C, 6th edition, the Logo problem in chapter 6. It was an interesting question with legal logical problems etc. The only question of…
-
10
votes2
answers5514
viewsIs there a correct way to comment on a code snippet?
Is there a correct way to comment on a code snippet? For example: // Esconde a tela this.Hide() or would be: this.Hide() // Esconde a tela or even: this.Hide() // Esconde a tela Is there some kind…
-
10
votes2
answers3616
viewsWhat is the difference between a file . c and . cpp?
C and C++ are two different languages, however C++ is a "superset" or superconpin of the C language. So what is the difference between a file with the .c and .cpp?…
-
10
votes1
answer421
viewsWhat are software design antiparks?
Is there a catalog of them for consultation, just as there is for design standards? Antipadrons are the same as bad practices?
-
10
votes2
answers188
viewsBoolean arguments, in general, are not good?
I was reading a little bit of Clean Code. The book talks about "good programming practices", and on the Internet, in one of the slides it is said that: Boolean arguments, in general, are not good. I…
encoding-style language-independent boolean argumentasked 7 years, 3 months ago UzumakiArtanis 9,534 -
10
votes1
answer382
viewsShould we use all variables as private?
We should always use the attributes of a class as private? What private variables help prevent? How do you decide whether a particular property should be private or not? CASE, by default, each…
php oop variables software-engineering encoding-styleasked 7 years, 7 months ago UzumakiArtanis 9,534 -
10
votes2
answers217
viewsWhy does this if check "if it’s ! false" instead of "if it’s true"?
I came across this piece of code: function showPrimes(n) { for (let i = 2; i < n; i++) { if (!isPrime(i)) continue; alert(i); // a prime } } function isPrime(n) { for (let i = 2; i < n; i++) {…
-
10
votes2
answers97
viewsIs it correct to program returning exceptions to the expected event?
When we are developing a software we can go through situations where something happens that we are not expecting and usually when it happens in many programming languages we can treat it within…
-
9
votes3
answers2573
viewsIs it possible to avoid using ifs in these cases?
I have read many materials on the internet about OOP, the overwhelming majority says to avoid if/else at all costs. For an OOP beginner like myself, many doubts arise. For example: if…
-
8
votes5
answers436
viewsRefactoring: When is a method "too big"?
I’m with a project that "recovers" certain information from an HTML page, makes a parse with the help of Beautiful Soup and return the values in the form of Dictionary, so that in another method I…
-
8
votes2
answers209
viewsProcessing time is affected by the size of variable names?
I was analyzing some frameworks developed by large companies and noticed a certain uniqueness, its variables and functions usually have small names. Variable or function name size interferes with…
-
8
votes2
answers214
viewsWhat happens if I don’t specify the { }?
I own this code that works normally: if($time <= time()) { if($time != 0) $Server->wsSend(1, 'perfect world'); foreach ( $Server->wsClients as $id => $client ) $time = time() +…
-
8
votes3
answers224
viewsUse of using versus full name
I’ve been following many projects open source and I realized that there’s a really big alternation between using using (Imports in VB.NET) and use direct reference to the namespace. Example: void…
-
8
votes1
answer442
viewsWhat is considered a "gambiarra" or a bad code?
For example, I create a code, and it works, but I’m not sure it’s right for me to do it that way. Is that a trick? I have to make sure that the code is done in such a way for it to be considered a…
-
8
votes3
answers1005
viewsForeach by reference or by value?
Is there a difference in performance and safety between using foreach by reference or by value? I always use the first option(when necessary) by finding the code less confusing to read. Reference:…
-
8
votes2
answers1281
viewsGood practices in declaring variables in a for
I’ve been making use of Resharper lately and I’ve enjoyed the experience of using it, but something’s been puzzling me. At times he suggests that certain variables be declared within some scopes, as…
-
8
votes3
answers374
views"== true" is useful for something? Is it better "!" or "== false"?
Place == true is useful in checking, or is completely useless? You better use ! or == false. Example: if (pessoa.estaMorta() == false) .... if (!pessoa.estaMorta()) .... if (pessoa.estaViva() ==…
-
8
votes4
answers121
viewsShould I use two IF’s or an operator?
Best practice for checking two conditions? In the example I’m going to give, are not very long checks but what is the best practice and what is the difference? (It happened to me that I found myself…
-
8
votes2
answers118
viewsWhat’s the difference between executing code inside or outside the "for" keys?
In Javascript or C, there is some difference between using for in the normal way: for(var i = 0; i < 10; i++){ console.log(i); } or execute the codes within the parentheses? Example: for(var i =…
-
8
votes1
answer150
viewsIs there any way to decrease the size of a function’s call?
Example: StringFormats.DateTimeToShortDateStrPtBR(); If you add this method several times in the same line the code will be very extensive, repetitive and confusing. The method is just an example,…