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
7
votes
1 answer

Declaring private constants outside of a class in Swift

When creating private constants in Swift it is possible to declare them within a class, final class SomeClass: NSObject { private let someFloat:CGFloat = 12 } as well as outside of a class. private let someFloat:CGFloat = 12 final class…
bmjohns
  • 6,344
  • 1
  • 33
  • 39
6
votes
1 answer

intellij ESlint + JavaScript Standard Style + Code Style Scheme none consistent

I have done the following: Installed JavaScript Standard Style globally. Set the standard in the IntelliJ ESLint settings. Set the JavaScript code style as Set From-->Predefined Style-->JavaScript Standard Style. When start coding (for example…
5
votes
1 answer

Prevent 0-ary functions from being called implicitly in Scala

I got nipped by a production bug where I passed an impure 0-ary function to a class that mistakenly expected a a bare result type. def impureFunc(): Future[Any] = ??? case class MyService(impureDependency: Future[Any] /* should have been () =>…
acjay
  • 34,571
  • 6
  • 57
  • 100
5
votes
2 answers

php codesniffer returns nothing ... is my code in standard?

I have a laravel application (created with composer) that I am trying to ensure meets PHP coding standards (level PSR-1). I run: $ phpcs --standard=PSR1 my_app/ And within a few seconds it returns with just a new, empty, ready-to-go command…
Laura_E
  • 169
  • 1
  • 10
5
votes
1 answer

Is there a way to attach a Javadoc doc comment to a Groovy script?

For a Groovy or Java class or method, I would generally include any API-level documentation in a doc comment (aka Javadoc comment), rather than a regular comment. What is the analogous way of adding such comments about a Groovy script? I personally…
M. Justin
  • 14,487
  • 7
  • 91
  • 130
5
votes
1 answer

PSR-2 CodeSniffer standard for eclipse plugin PHP_CodeSniffer

I'm using this eclipse plugin (http://www.phpsrc.org/projects/pti-php-codesniffer/wiki/) to check PHP code style. This plugin comes with some standards to check, but no with PSR-2. This plugin lets define a custom standard by giving a file. I've…
Jordi Martínez
  • 358
  • 3
  • 14
5
votes
3 answers

PHP (Nette framework) automatic coding standards check

I would like to have some type of automatic checking of coding standards for PHP Nette Framework is there anything like this? Standalone application or plugin for Eclipse, Netbeans ... For example to check Java code I use Checkstyle. Or can…
Amsik
  • 698
  • 2
  • 6
  • 26
5
votes
1 answer

Best PHP code style checker with Checkstyle-compatible output format

I am configuring CI server and want to add code style check step to build steps sequence. My CI server is TeamCity such code style check step must produce XML output compatible with codestyle format. I have found few tools for PHP code style check…
Ivan Velichko
  • 6,348
  • 6
  • 44
  • 90
4
votes
6 answers

Is the English language a standard to describe a Webservice (Rest, SOAP Etc.)?

In the current project where I'm working on, we had a discussion about the language (English or Spanish) we should use to describe pathnames, fields, payloads, Etc. I thought this was an easy topic, however, I couldn't find an accurate source where…
Ele
  • 33,468
  • 7
  • 37
  • 75
4
votes
2 answers

Powershell verb for destroying a resource

I've been trying to stick with the approved list of Powershell verbs when naming my cmdlets. I have a function which creates a resource, so it's called New-ClearCaseView. I'd also like to make a function which destroys this resource once it is no…
Tom H
  • 46,766
  • 14
  • 87
  • 128
4
votes
1 answer

PSR-2 compatible inline PHP tags in HTML templates

PSR-2 doesn't mention anything that would apply to the use of inline php tags in HTML templates, yet the php-cs-fixer tool seems to have a standard for it. This is my template file, before running php-cs-fixer on it:
Josh Harrison
  • 5,927
  • 1
  • 30
  • 44
4
votes
1 answer

Google CodeStyle for Eclipse formatter shows version warning

Style xml is taken from: https://code.google.com/p/google-styleguide/source/browse/trunk/eclipse-java-google-style.xml In Eclipse Luna (Version 4.4.1) go to: Window Preferences Java CodeStyle Formatter Import the eclipse-java-google-style.xml But…
heaphach
  • 1,492
  • 1
  • 20
  • 44
4
votes
2 answers

How to share eclipse Java/XML code style settings between developers?

In projects with many developers it is useful if all their IDEs are configured with identical code style settings, such that you won't get pseudo-differences due to changed formatting checked into version control whenever someone else changes your…
Dr. Hans-Peter Störr
  • 25,298
  • 30
  • 102
  • 139
4
votes
3 answers

Check property for null upon every use?

I just have a quick question to see what the best practice would be when making your own class. Let's say this class has one private member which gets initialized in the constructor, would I have to then check to see if this private member is null…
Feytality
  • 245
  • 2
  • 4
  • 14
3
votes
5 answers

Correct way to reset counter in COBOL

I want to know what is the better way to reset a counter. I have the following: 03 WS-SEQ-NO PIC 9(04). When WS-SEQ-NO is 9999, and i increment it, or if i move 10000 into it, it will get truncated, and become 0000. This is actually the desired…
Michael V
  • 41
  • 1
  • 4