Questions tagged [conventions]
A generic tag covering any accepted method of doing things, which could include naming, spacing, coding, commenting, etc.
1,121
questions
0
votes
1
answer
28
views
How to reproduce ASP.NET Core 6 conventions (post configure route)
Documentation contains something unclear and unbind to finally result description about conventions https://docs.microsoft.com/en-us/aspnet/core/razor-pages/razor-pages-conventions?view=aspnetcore-6.0#...
1
vote
1
answer
62
views
Is there a convention for JSON serialization of Python objects?
Is there a convention for JSON-serializing (and deserializing) Python objects to identify the object type? I've gone through this example solution below (which I find quite decent with slight ...
2
votes
1
answer
38
views
What should be the right "commit type" from conventional commit? [closed]
I created a commit with the purpose to unhide a feature, the code change is to only uncomment some lines of code and show the feature, so now the feature will be displayed to the user.
Should this ...
0
votes
0
answers
18
views
Slug - How to deal with Unicode or non-Ascii character
So I am learning Slug convention, but so far they mostly deal with English character, like "Hello world" would be converted to "hello-world", but there are very little information ...
0
votes
0
answers
14
views
Synchronous and Asynchronous code confusing definitions
I might have misunderstood or be missing something but I have to clear this issue:
Asynchronous code means code that gets executed with multiple operations at the same time, without blocking.
...
-1
votes
1
answer
37
views
Using import statements for packages and modules only, not for individual classes or functions
The google python style guide mentions at 2.2 that Use import statements for packages and modules only, not for individual classes or functions..
Why is importing functions or classes bad practice? ...
0
votes
0
answers
17
views
How would you improve this NodeJS code's structure, so I can learn to structure my code better?
I am relatively new to NodeJS, I am self-teaching a lot of it and I wanted to get some thoughts on the code I have written (shown below). It works for the function I wrote it to do, but I am certain ...
1
vote
1
answer
47
views
Abstract class selectively expose methods based on derived type
I am writing an program that implements a factory TimeManager to generate two types of objects; a Timer and a StopWatch. Both of these objects are derived from an abstract class TimePiece, and share ...
0
votes
0
answers
24
views
Build directory for ./configure?
Recently, I compiled gdb by using configure and make. To guarantee that the code was built into another directory (build), I executed the configure script from the build directory. (with ../binutils/...
0
votes
0
answers
57
views
I'm wondering what is the difference between ui and common inside components folder in vercel/commerce next.js example source code?
I try to follow vercel next.js example folder structure, but don't know what is the difference between ui and common inside components folder in vercel/commerce next.js example source code.
It seems ...
-1
votes
1
answer
72
views
Should I remove the OnInit implementation which is generated when a component is created by the Angular CLI if it isn't strictly necessary?
My team is working on an Angular project and are trying to establish team code style conventions. A teammate has encouraged me to remove the OnInit implementation which was generated when I created ...
-1
votes
3
answers
47
views
Overriding "constants" from parent class python
I have a simple inheritance setup as follows:
class A:
CONST_VAR = "aaa"
# more code where CONST_VAR does not change
# ...
class B(A):
CONST_VAR = "bbb"
# more ...
0
votes
1
answer
24
views
Changing hidden inherited attributes in python
I have a child class where I wish to overwrite an attribute from the parent class. The problem is this attribute is wrapped in a getter, and so to change it I have to access an underscored variable - ...
1
vote
0
answers
168
views
What is the most common name for staging/pre-production/prod-like deployment environment?
We use several different names for the "staging/pre-production/prod-like" deployment environment in our organization. This environment is very close to production and we do final tests there ...
0
votes
0
answers
13
views
Are there any conventions for templating code?
Are there any conventions for how we should template code? For example, if I am writing an if else in JS and I'm not sure how to complete it, can I just put ...'s to mark where I will fill the code in ...
0
votes
1
answer
88
views
In Java coding convention, for multiline if condition, where to place the logical operators? [closed]
In the multiline if condition, I would like to know if we follow a convention where to place the logical operators (&&, ||) or if it's just a preference.
Say we have this kind of if condition ...
-1
votes
1
answer
40
views
Argument convention in PyTorch
I am new to PyTorch and while going through the examples, I noticed that sometimes functions have a different convention when accepting arguments. For example transforms.Compose receives a list as its ...
0
votes
1
answer
32
views
Laravel class usage guide? [closed]
I am a PHP beginner and learning Laravel (currently Laravel 9). I have seen some tutorials, and I am experimenting with them. I noticed that there are many classes defined in the framework itself. I ...
0
votes
0
answers
50
views
URL language naming convention for non-English websites
I am developing a website for a French audience. There seem to be an incompatibility between independent best practices :
Naming frontend urls in the audience's language for SEO and audience's ...
-1
votes
1
answer
44
views
REST conventions for a friends list
I have a database (ORM) with users which look like this:
UserEntity (
id: UUID,
name: String,
phoneNumber: String,
friends: List<UserEntity>
)
I also have the following friends ...
0
votes
0
answers
17
views
Why some vendor-specific MIME types do not have the vnd. prefix?
According to RFC 6838,
The vendor tree is used for media types associated with publicly available products.
...
Vendor-tree registrations will be distinguished by the leading facet "vnd.".
...
0
votes
0
answers
23
views
canonical use of _ as a variable in python [duplicate]
I'm currently reading a textbook studying machine learning and I came across a strange variable in the example code.
class Regression(object):
# __init__
# set_data
def regress(self, query_point):
&...
1
vote
0
answers
58
views
After I apply intellij-code-formatter.xml, the xml indent fommated as strange form
env: spring boot 2.6, mybatis, intelliJ
I apply formatter xml.
but I use ctrl + alt + l (window) formatting short cut
then mybatis.xml formatted like below,
which tag can fix this (normal format)? ...
0
votes
1
answer
78
views
What is a convention for indicating the intended flavor of a Markdown script?
There seem to be a lot of flavors of Markdown. What are any conventions for indicating the target flavor within a Markdown script? Perhaps something similar to:
<!DOCTYPE Markdown "Jupyter ...
0
votes
1
answer
210
views
What is the "Common" folder used for in software files?
After looking through software files, I often came across a folder named "Common".
I suspect this is only used for convention and can be used however the developers desire, but what data is ...
0
votes
0
answers
29
views
Oauth redirect endpoint - should it be verified to avoid unwanted traffic to domains that are not under the client's control?
I'm exploring the best practices in implementing OAuth for our users. When our users are creating a client, they are also registering an endpoint where they can be redirected to during the ...
0
votes
0
answers
101
views
Using DTO or request.param in Express/TypeORM Rest Api
Im creating a REST API with express/TypeORM in Typescript.
My application stores users in mysql database, and users can create boards in the application.
When a user create a board i have to send the ...
0
votes
0
answers
32
views
Eclipse is insisting that project name must be a lowercase while not letting me progress to the next step
Name(MyGraphics) must start with lowercase
"next", "finish" links are grayed out when same(myGraphics) starts with lowercase
0
votes
1
answer
75
views
Is there a convention in using dict vs curly brace initialisation when using Plotly? [duplicate]
The docs for Plotly and many answers on Stack Overflow trend toward using
dict(foo=bar)
instead of
{'foo':'bar'}
Is there a particular reason for this preference? I've been told in the past that ...
0
votes
1
answer
37
views
Is it good practice to use a for-loop to set a variable?
For example, if I wanted to set x to the first element in an array that isn't equal to 0, I could write:
int x = 0;
for(; x<arr.length && arr[x] != 0; x++) {}
//use x
Is this bad practice?...
0
votes
1
answer
463
views
Should properties of constants be capitalized? [closed]
I know that it is conventional to capitalize constant values in programming, but would you do the same for their keys? I am trying to make a string based enum in javascript:
const SEASONS = {
spring:...
-1
votes
2
answers
69
views
Is there a way of naming conventions for a specific identifier?
So I have been set this task for revision and I am unsure as to what the question is implying:
Because identifiers in a programming language cannot contain any spaces, programmers use conventions when ...
0
votes
0
answers
41
views
In C# how do I get Conventions from Context object in EF 6?
I would like to get Conventions that were created on OnModelCreating, from my context object.
Example:
public class MyContext: DbContext
{
public MyContext(): base(System.Configuration....
1
vote
2
answers
66
views
Disable warning about Capitalized function names
I am working on building a DSL using Kotlin for a specific part of our application (in its own module). But, IntelliJ keeps complaining about capitalized function naming...This is how I would like to ...
2
votes
1
answer
75
views
How would you create your own default layout in Yesod?
I'm a C# back end developer trying to learn web dev with haskell and Yesod, so please bear with me.
My question is, what is the convention regarding creating your own default layout. Should you create ...
1
vote
2
answers
132
views
Pass a pointer instead of return new variable in C and Go?
Why is it convention in C and Go to pass a pointer to a variable and change it rather return a new variable with the value?
In C:
#include <stdio.h>
int getValueUsingReturn() {
int value = ...
2
votes
1
answer
234
views
Why should lambda argument be moved out of parentheses?
Kotlin coding conventions (https://kotlinlang.org/docs/coding-conventions.html#lambdas) say:
"If a call takes a single lambda, pass it outside of parentheses whenever possible."
What is the ...
1
vote
3
answers
764
views
What is good naming convention for validating method? [closed]
Let's say there is a method validating user's input. This method check if there is any duplication in list, and if exists, throw some kind of exception.
In this situation, which is proper naming for ...
0
votes
0
answers
93
views
Performance & best practices on when to use code vs template in Angular
First, the scenario:
Let's say I have a "menu", with internal links to other routes in the application, where each link has an identical structure with only differing properties. Nothing ...
6
votes
1
answer
117
views
Julia type conversion best practices
I have a function which requires a DateTime argument. A possibility is that a user might provide a ZonedDateTime argument. As far as I can tell there are three possible ways to catch this without ...
0
votes
1
answer
825
views
Python git project-structure convention? [closed]
Is there a convention(or even a PEP) on how to structure a python project for example on GitHub? More specifically python-specific files(I know about the README.md, licence, .gitignore-files).
I've ...
-3
votes
2
answers
46
views
Better style in SQL? [closed]
I have several queries that look like this:
SELECT name
FROM people
WHERE id IN (SELECT person_id
FROM directors
WHERE movie_id IN (SELECT id
...
-1
votes
2
answers
66
views
Coding convention for If statement and returning [closed]
I'm not sure if I'm overthinking this but should I do this
if (!searchList.isEmpty()) {
String search = searchList.get(0).getText();
return List.of(search.split("\n"));
} else {
...
2
votes
1
answer
90
views
Is there any rule against putting more than one parameter in a mutator?
I need my mutator to call a different function in my constructor and another function anytime after that, so I was thinking of putting a bool as a second parameter to differentiate as follows:
void ...
0
votes
0
answers
187
views
Strong Parameters #require Convention in Rails API
I understand how the #require method works, but why/when should it be used. Is using require a best practice and why?
At least for simple controllers and parameters, require seems pointless.
For ...
3
votes
1
answer
105
views
Are there different types of Arrays in JavaScript?
This is the console output of two different "arrays" made up of the same strings. I do not know how they originated (there is lots of code that I did not write) but I believe only Object2 is ...
-1
votes
1
answer
70
views
How to use a variable named 'type' in Scala class definition? [duplicate]
I have to create a class that in its definition contains a variable named 'type', for example like this:
case class testEntity (
type: String,
val: String
)
Is there any possible to do that?
1
vote
3
answers
89
views
Dart convention for assigning doubles
Is there a convention in dart for assigning doubles?
I mean, a guide which says about which style is preferred between
double aDoubleValue = 200;
and
double aDoubleValue = 200.0;
This page has a ...
0
votes
0
answers
32
views
In "You shouldn't document exceptions that get raised if the API specified in the docstring is violated ",do I write type exceptions explained in Args
The Google docstring styleguide for python writes
You should not document exceptions that get raised if the API specified in the docstring is violated (because this would paradoxically make behavior ...
0
votes
0
answers
52
views
What is the correct controller for the comment `create` function for when the route is "/posts/x/comments" according to conventions & best practice?
When i have the route /posts its clear for me that the post create function for this route should be in the PostController.
When i have /posts/x/comments i would expect that the comment create ...