Skip to main content

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
2 votes
5 answers
607 views

Is Exception caught in the Service class a matter of preference?

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,909
-4 votes
1 answer
85 views

Feedback on custom "Orchestration" architecture

I've been doing some deep thinking on how to structure code and found myself coming up with a (for me) new pattern. The pattern is based on a highly modular approach with a large focus on indirection, ...
Felix ZY's user avatar
  • 101
0 votes
2 answers
154 views

Should each commit in a branch implementing a new feature be prefixed by "feat:" using conventional commits?

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
259 views

Considering IDE and text editor features when choosing a coding style

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 ...
Critical Failure- Core Dumped's user avatar
0 votes
1 answer
56 views

Wrapper Auxiliary Method VS Default Arguments for Initialization: Pros/Cons

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
220 views

Creating necessary documentation for maintenance staff when only Code repository contents can be relied on [closed]

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
451 views

Should entities always be simple and mapped?

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
58 views

Are type, constant/static/global, and pointer prefixes still necessary in C coding standards, considering the capabilities of modern IDEs? [duplicate]

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
359 views

Is storing computed values always bad?

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
82 views

Practical Advice for rapidly changing code maintainability [closed]

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
340 views

Naming a method that does the same thing faster but only approximates the result?

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
185 views

What is point of having certain microservices making another API call in the same service

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
346 views

How to label backwards incompatible changes which change the API but don't add a feature?

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
1k views

Are there advantages to using an interface, rather than a class, for a Java application?

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,315
0 votes
2 answers
634 views

Can a UUID be called a constant?

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
1 vote
0 answers
416 views

Is non-contiguous protobuf field numbering an anti-pattern?

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,036
4 votes
5 answers
907 views

Why are vertical and horizontal spacing heavily used in coding styles?

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
3 votes
4 answers
941 views

Is the combination of state machine and pure function a programming style?

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
11 votes
5 answers
6k views

Should an optional boolean function argument rather default to true or false?

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,456
56 votes
7 answers
13k views

Why do so many standards for JSON API response formats contain a "success" property in the response body instead of just using HTTP status codes?

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
  • 679
3 votes
1 answer
4k views

Naming convention for the classes holding REST APIs [closed]

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
  • 149
13 votes
6 answers
5k views

Is it bad practice create "alias" variables to not use globals or arguments with long names in a method?

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
191 views

best practice for error handling between PAM_SUCCESS and PAM_AUTH_ERR macros

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

Adding Units To Magic Numbers

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
270 views

Is a good practice using form tag's atributes in HTML?

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
296 views

ASPICE assessment: detail of test logs

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
216 views

Java Coding standards via common and open source tools?

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
476 views

Assumptions versus no assumptions - where do you draw the line? [closed]

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
249 views

Should we put behaviors (method) in constant class in Java?

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
69 views

Pros and Cons of placing a method as static in the class or as private function outside of class when it doesn't utilize this?

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
5k views

Why would you ever want WET code?

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
161 views

General term to describe the anti-pattern where the same concept is described in different ways?

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

Passing object or using the field

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

Error handling. Is it always necessary?

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
86 views

Download and apply or apply as they download, is there a best practice?

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
383 views

Two different styles of functions: does either have an advantage?

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
523 views

Should default settings be considered as business rules from the viewpoint of "Clean Architecture"?

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
80 views

What could be a better naming convention for the variable 'completeConfig'?

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
298 views

Which approaches are exists for using of possessive case in variables/classes/methods naming?

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
204 views

counting identifiers and operators as code size metric

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

Negative Naming in Forms

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
427 views

Cyclomatic complexity vs repeated code

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
565 views

Current industry standard with regards to C macros [closed]

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

Is this enum/trait a good way to implement polymorphic design in Rust?

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
295 views

Microservices Conditional API Call Design

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
545 views

What is the disadvantage of learning to code by doing?

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
4k views

Why would you ever use `malloc(0)`?

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,438
-2 votes
4 answers
183 views

Are there any guidelines about making SQL queries easier to comprehend?

As I'm spending more time working with SQL, I'm starting to feel like this language promotes logic obfuscation. Here are some examples: An INNER JOIN in a query can act as an implicit filter that ...
Primordial_Hamster's user avatar
1 vote
6 answers
4k views

Naming boolean fields in classes

I have had hard times naming boolean fields. On the one hand, i've read that it is good to name them as affirmative statements, like hasAge, or canDance. It's not a problem when naming local ...
Kamil Bęben's user avatar
2 votes
3 answers
685 views

Changing control name property during runtime -- Why doesn't anything break and why shouldn't I do it?

To make a long story short, I needed a property of a button to act as a "secondary text property" and retain the original .Text value of a button, and the only String property that wasn't ...
Hawkeye's user avatar
  • 147

1
2 3 4 5
12