Questions tagged [code-standards]

*Coding standards*, or *coding conventions*, are sets of rules or guidelines designed to govern the process of code production in a software project. They're usually based on industry best practices or generally accepted conventions.

Coding standards, or coding conventions, are, in essence, sets of rules or guidelines designed to govern the process of code production in a software project, based on industry best practices, and, as such, they have been around for almost as long as programming itself. They are often applicable to a specific programming language, library, framework or environment, but they can also be language-independent, focusing mostly on style.

While coding standards can be somewhat informal, defined by a small team or corporation for internal use, most adopted standards aim to provide a formal definition of their rules, the reasoning behind each rule, and whether (and how) compliance with those rules may be verified. The main advantage of adopting coding standards, regardless of the formality and reasoning of a standard, is to have consistency across a code base.

In practice, to a programmer, complying with coding standards means restricting oneself to a subset of the programming language's features or syntax rules, in virtue of consistency, robustness and code readability. This tends to result in increased team productivity and reduced maintenance and production costs.

118 questions
0
votes
2 answers

Using static import fields for constants?

I have stumbled upon some existing code which is using static import for constants. import static com.zee.SelfServiceConstants.ATTR_SEV; import static com.zee.SelfServiceConstants.ATTR_SEV_CRITICAL; and it is used in the same class…
Zeeshan
  • 11,851
  • 21
  • 73
  • 98
0
votes
1 answer

Is There A Term For A 'Processing' Object? (Not Quite A Factory Object)

The term factory applies to objects that create and return objects. Is there are term for classes that modify other objects and return that modified object? I looked for terms like 'Processers' and 'Modifiers' but didn't turn up much (other than…
Aggressor
  • 13,323
  • 24
  • 103
  • 182
0
votes
1 answer

Moodle PayPal Enrolment, how to add a currency?

I would like to add the ZAR to the list of available currencies in the PayPal plugin. I can do this by hard coding. I add 'ZAR' to PHPPlugin->lib.php->enrol_paypal_plugin->get_currencies->$codes However this is hard coding and I have been told to…
JMB
  • 23
  • 1
  • 3
0
votes
1 answer

jquery applying class to items in a loop

I am trying to apply class to all date items in a loop. My code is working but i am 100% sure that they way i wrote code is not right. Could some on suggest on the code changes. I want to use a FormatDateTime function(my own function) on date item…
Kurkula
  • 6,386
  • 27
  • 127
  • 202
0
votes
2 answers

JavaScript code standards checker

Are there any code standards/style guide checkers for JavaScript? Basically, the equivalent of PHP_CodeSniffer, but for JavaScript.
samanime
  • 25,408
  • 15
  • 90
  • 139
0
votes
1 answer

Following standards or not

Traditionally BASIC offers the question mark (?) character as an abbreviation for the PRINT command. I did not find this feature in the BASIC standard ECMA-116. Does anyone know when or why it was introduced in the past? Should a modern day BASIC…
Sep Roland
  • 33,889
  • 7
  • 43
  • 76
0
votes
3 answers

Whats a Strong Argument against Variable Redundancy in c code

I work in safety critical application development. Recently as a code reviewer I complained against coding style shown below, but couldn't make a strong case against it. So what would be a good argument against such Variable redundancy/duplication,…
ACoder
  • 1
0
votes
1 answer

Coding standards / formatting

I'm often modifying code that was written by others. I've seen a lot of code formatting standards and I'm a bit confused what I should do. Should I always stick to my own standard or adjust my standards to the one used in the framework? Currently…
0
votes
5 answers

Nice way to make a limit to the value

I have a code with pixel brightness that is limited to [0..255]. And it's evaluated for some reason, so I can get value outside the bounds. I can do (if x>maxValue) x = maxValue; or x = min(x, MaxValue); or (x > MaxValue) ? MaxValue : x; but I…
Pavel Oganesyan
  • 6,774
  • 4
  • 46
  • 84
-1
votes
2 answers

Are there penalties for just using the new keyword instead of creating a class variable before calling the class method?

Example (1) var classVar = new class(); classVar.Method(); (2) new class().Method(); I like the second way, less wordy. Is there a performance difference? Is it considered bad coding practice?
BenG
  • 19
  • 4
-1
votes
1 answer

Difference between dynamic boolean expression variable and boolean function

I came across this doubt: what is the difference between these two ways of getting a boolean value? The end result is the same, but what are the advantages and disadvantages of using one or the other? What's the most used approach? What is the best…
Oliver
  • 926
  • 2
  • 12
  • 31
-1
votes
2 answers

should i use strings.xml for readability in the long run?

mainly concerned about code readability & maintainability in the long run, my application will never be localized and little to none strings duplication textView.setText(context.getString(R.string.string, arg)); in comparison…
Alon Aviram
  • 190
  • 1
  • 15
-1
votes
5 answers

What is the difference between the following try-catch statements?

What is the difference between these usage of try-catch blocks and when you should use each one? try { doSomething1(); } catch(Exception e1){ exception_handle1(); } try { doSomething2(); } catch(Exception e2){ exception_handle2(); } try { …
Ari M
  • 1,386
  • 3
  • 18
  • 33
1 2 3 4 5 6 7
8