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

Java common Try/Finally block around different code blocks - code style

I have the same if() { try { < SOME CODE > } finally { } } else {} block that I use in 3 methods. The only thing that's different in each method is < SOME CODE >. Are there any coding patterns that I can use to "DRY" my code? Ideally would like to…
John Fitch
  • 113
  • 1
  • 6
0
votes
1 answer

Format code to align with its own subsection clause

Currently using IntelliJ 2018.2.3. What option(s) in the Code Style (or anywhere else) should be checked/unchecked to achieve the following behavior? Intended behavior: @Override public boolean equals(Object other) { return other == this //…
Zhi Kai
  • 1,549
  • 1
  • 13
  • 31
0
votes
1 answer

How do I enforce the opposite of whitespace check-branch in TSLint?

I would like to enforce the opposite of what whitespace check-branch does. So instead of having this: if (condition) { return true; } else { return false; } I would like to enforce this: if(condition) { return true; } else { return…
Chris
  • 987
  • 6
  • 24
0
votes
0 answers

ASP.NET MVC use editor template for object creation

On my index.cshtml the model is a list of Person. I want to display these Persons on the page. However, on the same page I want to show a dialog that allows a new Person to be created via ajax. It seems like a violation of DRY to recreate the…
Nformer
  • 91
  • 2
  • 7
0
votes
2 answers

SonarQube maven compatibility (Unsupported major.minor version 52.0)

I have a multi-module maven project with the following versions of softwares: Maven : 3.2.1 JDK : 1.6 sonar-maven-plugin : 3.4.0 SonarQube server : 6.7.0 (Build 33306) I get the following error on running clean sonar:sonar : [ERROR] Failed to…
saupan
  • 273
  • 3
  • 6
  • 15
0
votes
1 answer

Best Jenkins Plugins for Coding Standard Validation against build ( For .NET )

I am looking for something which will automatically validate the coding standards in Jenkins. I have seen some plugins for that like OSWAP Dependency check, CheckStyle, Dry, Findbugs, Violations (Fxcop, Stylecop), Warning etc. All projects are made…
0
votes
1 answer

Is it good practise to extract strings from framework standard syntax?

For example: In sonata admin, a single admin class has always recurring syntax like $formMapper->add('test', null, ['label' => 'testlabel']); $formMapper->add('test1', null, ['label' => 'testlabel1']); $formMapper->add('test2', null, ['label' =>…
Jim Panse
  • 2,220
  • 12
  • 34
0
votes
1 answer

Fully-Qualified Names in JavaScript

In .NET we have the concept of a fully-qualified type name. For example, we have System.String, where System is the namespace, and String is the type. Subsequently, we can have member FQNs, e.g. System.String.Substring, where Substring is a…
Den
  • 16,686
  • 4
  • 47
  • 87
0
votes
2 answers

How can this code be written shorter/clearer?

newRow("OrderReference") = line.Substring(line.IndexOf("*1003") + 5, line.IndexOf("*", line.IndexOf("*1003") + 5) - line.IndexOf("*1003") - 5) There you have it. Very long and ugly. I was thinking about this: Dim indexPlus = line.IndexOf("*1003") +…
Karl
  • 410
  • 11
  • 25
0
votes
1 answer

Entity and DTO communication between modules

I want to know the best practices. Following things are confusing: 1) Should model return an Entity or directly a DTO by using select new ExampleDto(...)? 2) How we should convert Entity to DTO or vise versa? 3) Can we use the DTO for Entity to DTO…
MDaniyal
  • 1,097
  • 3
  • 13
  • 29
0
votes
1 answer

PHP - "more that zero" in if condition

Often in php i see code lines like if(count($arr)) // $arr not empty or if(!$var) // $var is 0 But for me more informative is style like if(count($arr) > 0) // or if(!empty($arr)) or if($var == 0) Which do same checking. What option is more…
f0rtis
  • 326
  • 2
  • 13
0
votes
1 answer

Passing an object between the methods which has to keep adding data in all the methods

I have a requirement of passing the object between methods and adding data as below example. Is the below written code is a good programming practice? public void parentMethod(){ PropertyBean propertyBean = new…
Janardhan
  • 13
  • 6
0
votes
4 answers

Javascript module Pattern with Namespacing

I have been practicing with JavaScript module pattern with proper Name-spacing. So basically I declare namespaces and each namespace has certain modules encapsulated in it. Here is what I have written so far. The code has been commented properly.…
Talha Masood
  • 993
  • 1
  • 7
  • 22
0
votes
1 answer

VBA Code Standardisation Practices

I've been applying VBA at work for a number of purposes. I have noted the more 'clicks' a user has to do for a form (with a number of macros), the higher the rate of error. I was wondering rather than having 3 separate functions requiring 3 separate…
IronKirby
  • 708
  • 1
  • 7
  • 24
0
votes
1 answer

Should I store an HTML form in a database

I am wondering if it is considered bad practice to store HTML content in a database or if it is unsafe. I am looking to implement several forms into my system that will have different fields and can change regularly. I am wondering if it would be…