Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

Questions tagged [coding-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. They include naming conventions, style, prohibited features, and more.

Filter by
Sorted by
Tagged with
0 votes
3 answers
246 views

Question Body I'm currently developing a Python coding standard for use in enterprise-level internal systems. Our typical use cases include: API input/output validation Reading from databases, ...
agolta's user avatar
  • 77
3 votes
6 answers
602 views

I'm currently drafting a Python coding standard for internal enterprise use, primarily targeting business applications that involve heavy data access, reporting, and transactional logic. In this ...
agolta's user avatar
  • 77
2 votes
4 answers
489 views

Threre are two functions FindMaxDistanceVector and FindMaxDistanceList whose implementation is almost same except some debug information added in FindMaxDistanceList. Note that these two functions are ...
user146290's user avatar
2 votes
4 answers
527 views

According to Wikipedia, Call super is a design anti-pattern in which a particular class stipulates that in a derived subclass, the user is required to override a method and call back the overridden ...
VL-80's user avatar
  • 131
2 votes
5 answers
746 views

In a Java EE legacy project, almost all the DAO and Service classes are written in a a way that DAO level does not catch any exception and instead the service classes catch(Exeption e) in all of their ...
Rui's user avatar
  • 1,935
0 votes
2 answers
352 views

Consider I'm working on a branch feat-1 implementing a new feature. I'm confused what to prefix each commit with on that branch. Should they all be prefixed with feat: (after all, they are all part of ...
Shuzheng's user avatar
  • 109
1 vote
3 answers
308 views

Recently, I had a debate with one of my friends on using type inference in C# (var keyword). His argument was that we should stick to using the explicit type names because "even with the ...
Zombies are Real's user avatar
0 votes
1 answer
67 views

I have a class in which there are several methods that can act as an "entry point" to its private innards (or the "fruit" thereof). Said functions might be called multiple times ...
Shay's user avatar
  • 103
0 votes
1 answer
315 views

Conditions: stable legacy prod system no Software Devs of the system are available anymore app is maintained by Engineers, who do not have the same software dev experience like the original Devs and ...
stack3r's user avatar
  • 125
0 votes
2 answers
692 views

I am told everywhere that entities are only to represent the data structure, then entities should be mapped to a model and then the model possibly to a DTO. The other way is similar, DTO -> model -&...
Gersalom's user avatar
0 votes
0 answers
59 views

Our coding standards for C include various prefixes for data types, constants, static/global variables, and pointers. These prefixes were originally introduced for code review purposes, but with the ...
Cem Polat's user avatar
  • 127
1 vote
5 answers
398 views

Edit: I'm copying the question but changing the example code. Apparently, I used a bad example earlier that contained an imprue getter. I'm keeping the old example code at the bottom so the first ...
sharbel okzan's user avatar
0 votes
1 answer
88 views

This question may get closed quickly, but I'll appreciate any advice I can get and all the resources I can find online about this topic aren't quite relevant to my case. I am a Math PhD student doing ...
msm's user avatar
  • 109
4 votes
5 answers
363 views

Presume I have a function that does some precise calculation on a large amount of data, call it calculateResult(data). This function gets very slow with increasing size of input. Luckily, I only need ...
csstudent1418's user avatar
-1 votes
1 answer
217 views

I was going through an old, largely untouched part in my company’s codebase and found one API. It does the following things. A POST API with path host/entities/trigger which fetches a list of entity ...
elliot's user avatar
  • 11
4 votes
1 answer
368 views

I have a project in which I'm the sole contributor, there isn't a stable API yet and I'm constantly refactoring code, but I still try to denote breaking changes whenever they do happen. Recently ...
Clara's user avatar
  • 53
8 votes
4 answers
2k views

Java is often (rightly IMHO criticized) for overusing the class keyword, as it can denote: a factory to instantiate objects (traditional classes) a collection of global methods (when all methods are ...
Ray Toal's user avatar
  • 1,325
0 votes
2 answers
756 views

From my understanding, a constant is a value which is assigned only once and cannot change at runtime, whereas variables have mutable values which are unpredictable by nature. My question is, to what ...
Clara's user avatar
  • 53
2 votes
0 answers
569 views

Is it an anti-pattern to have gaps in field numbers to aid readability? The need being address by this idea is that metadata fields, which are "aspect" fields, can be placed in the proto ...
Bohemian's user avatar
  • 2,076
4 votes
5 answers
1k views

Why would so many repositories use additional — apparently unnecessary — vertical and horizontal space in coding styles? I almost unanimously see this: public function getName() { ...
Nobody-Knows-I-am-a-Dog's user avatar
4 votes
4 answers
1k views

As a university student who just have been learning programming for a year. After I learned about the concept of state machine and the pure function in functional programming, I suddenly got an idea ...
Equescript's user avatar
12 votes
5 answers
7k views

In many cases I can formulate some boolean parameter equally well positively as negatively, e.g. isOn or isOff. Which one should I pick then, in case I want the argument to have a default value? Is ...
DaveFar's user avatar
  • 1,466
57 votes
7 answers
15k views

I was researching about best practices for standardised JSON response formats for APIs, according to various sources available online general consensus looks something like this: //Successful request:...
Šime's user avatar
  • 689
4 votes
1 answer
5k views

Our new team suffixes class names with API to indicate that they encapsulate RESTful methods. Eg: "PaymentTemplateAPI", "FeeTemplateAPI" classes. I find it odd since API is a ...
explorer's user avatar
  • 159
13 votes
6 answers
6k views

Is it OK to create a variable which only purpose is to increase readability? Example: public class Example { private final HowLongCanARepositoryNameReallyBeRepository ...
Adilson Cabral's user avatar
0 votes
5 answers
224 views

We have two exit code code PAM_SUCCESS(0), PAM_AUTH_ERR(7). If we wanna return 0 or 7 when we compared password with our password in following code which code is better that this code ? if (strcmp (...
alirezaarzehgar's user avatar
18 votes
4 answers
4k views

Considering this question and the most upvoted answer, and his specific example of public static final int THREE = 3; might it make sense to allow this sort of usage if we added units to the ...
Onorio Catenacci's user avatar
0 votes
1 answer
297 views

Checkout this HTML using the attribute action, method and target from <form></form> tag: <form action="/action_page.php" method="get" target="_blank"> ...
Renato Junior's user avatar
0 votes
1 answer
339 views

The "VDA Automotive SPICE Guidelines" (excerpts: https://vda-qmc.de/fileadmin/redakteur/Software/Automotive_SPICE/Veroeffentlichungen/VDA_Guideline_Rules_and_Recommendations_2017.xlsx) tells ...
kaay's user avatar
  • 109
-3 votes
2 answers
301 views

I'm working on a project with 3 other backend developers and 3 front end devs. Also playing the role of architect for 3 other projects. One issue I see is that most developers are not formatting code, ...
tgkprog's user avatar
  • 610
-2 votes
1 answer
562 views

In our line of work as software engineers, we can write code that assumes various things outside its scope or architectural boundary, in order to save performance, time, and on defensive coding ...
SpiritBob's user avatar
  • 105
0 votes
2 answers
298 views

Should we put behaviors (method) in constant class in Java? If not then why? Which clean code practice/principle I am breaking while doing that? public class TagConstants { public static final ...
Pulkit Gupta's user avatar
0 votes
1 answer
73 views

I use TypeScript. When I write the below code ESlint throws this error: https://eslint.org/docs/rules/class-methods-use-this export class { constructor() { const result = doCalculations() ......
demiculus's user avatar
  • 109
7 votes
9 answers
6k views

We have all heard of Don't Repeat Yourself and Write Everything Twice, but I've never understood why anyone would prefer the latter of those. Obviously you can go overkill with DRY, with the code ...
JensB's user avatar
  • 277
-3 votes
1 answer
186 views

Our codebase is old and very large. Over the years, many developers have worked on the code and frequently refered to the same concept inconsistently. For example, we have a "number that uniquely ...
AlainD's user avatar
  • 150
4 votes
3 answers
1k views

I would like to know what is a more appropriate way to code in Java. Is it generally better to pass entire objects in the method's parameters or just using the fields from the class? Using the field: ...
max's user avatar
  • 163
2 votes
3 answers
2k views

So, today I was reading a piece of code I found this function: Public Function FolderExists(sPath As String) As Boolean Dim FSO As New FileSystemObject On Error GoTo errHandler sPath = ...
DT1's user avatar
  • 209
4 votes
1 answer
93 views

I am writing a function that will download an HTML post. Having downloaded the string I will: strip off the html tags remove special encoding characters like \n remove trailing white spaces My ...
Eduardo's user avatar
  • 151
4 votes
5 answers
408 views

In the past few months that I've been learning Javascript, I've wondered which is the better usage of functions: Functions that perform actions based on their arguments with no return value: const ...
literal240's user avatar
0 votes
2 answers
572 views

The examples of default settings: Default port for server applications Default resources directory for Java Applications Default Webpack config file ("webpack.config.js") My particular ...
Takesi Tokugawa YD's user avatar
-3 votes
1 answer
96 views

I have a feature in which the user can directly provide the entire nginx config inside the completeConfig variable in the config yaml. Like this: nginxConfig: completeConfig: > .... .... ...
Siddharth Gupta's user avatar
0 votes
2 answers
327 views

In variables/classes/methods naming, sometimes "of" preposition is omitted and word order changing, for example: "Absolute path of source file of entry point" -> "...
Takesi Tokugawa YD's user avatar
1 vote
1 answer
222 views

I'm looking for a code metric for monitor and track over time the size of several projects and their components. Also, I would like to use it for: evaluate size reduction after refactoring compare ...
Guish's user avatar
  • 23
-3 votes
4 answers
1k views

The Main Question Is it ever acceptable to use a negative name for a boolean variable? For example, I have a few user forms that have a checkbox for "N/A" or "Not Assessed". These ...
Shaun H.'s user avatar
1 vote
1 answer
468 views

we've a python function that can be achieved in 2 ways 1st method def complexity_1(x, y): if 2 == x and 3 == y: a=3 b=4 c = a + b elif 2 == x and not 3 == y: a =...
janardhan reddy's user avatar
-5 votes
2 answers
701 views

I have read from several authors that macros in C should be avoided whenever possible, and use inline functions instead. It's true that inline only 'requests' the compiler to replace the function call ...
Martel's user avatar
  • 615
3 votes
1 answer
3k views

this is my first post on here, and I'm wondering about a good rust implementation with traits on enum types. I want to know if using an enum w/ a trait as a generator of different code is viable like ...
Truffle's user avatar
  • 39
0 votes
1 answer
323 views

I always think about this scenario where we need to perform a task conditionally and the task requires calling another microservice. What I am not able to understand is which microservice's ...
rohanagarwal's user avatar
1 vote
4 answers
579 views

It seems like the consensus is to learn by doing when it comes to programming, well that seems like the advice given to most beginners. How will beginners learn to write efficient code when they dive ...
Hisham Mohammed's user avatar
12 votes
4 answers
5k views

While reading an answer here, I saw this code: char ** v = malloc(0); while ((r = strtok(s, " ")) != NULL) { char ** vv = realloc(v, (n+1)*sizeof(*vv)); The thing that bugged me was the ...
klutt's user avatar
  • 1,448

1
2 3 4 5
12