1,154
questions
0
votes
0
answers
12
views
Does a named standard exist for comment annotations?
I have encountered, and used, several different forms of comment annotations. Eg.
// TODO: Also trigger this task
// FIXME: in this very specific circumstance this should handle this way instead
// ...
1
vote
1
answer
88
views
Why do Lisp style guides recommend the specific numbers of semicolons for comment in several cases?
I read in the style guide of Elisp and of Common Lisp to use specific numbers of semicolons in various cases, in short this:
single semicolons for comments at the ends of code lines
double semicolons ...
-1
votes
1
answer
28
views
Where do you set default values when registering a user? [closed]
i am currently developing a web application in which the user should have the possibility to register. For this I have built a VueJS web application and a Golang REST API.
However, the backend is now ...
0
votes
1
answer
39
views
Long format dataframe column hierarchy
I am working with long format dataframes and intend to write a package myself. While it is not crucial, I would like to adhere to common practice of column hierarchy, e.g. when I have 3 participants ...
1
vote
2
answers
69
views
How do I reduce repetitive error handling in java
So I have a code snippet similar to this. I feel like the if statements should be in a common function. I am not sure how to handle that because school and student should be passed to this function ...
0
votes
1
answer
32
views
Forcing integer input using the isdigit() method
Is the following code conventionally acceptable and what are some problems that may arise from implementing the required solution in such a manner?
while True:
Iq = input("What is your Iq? &...
0
votes
0
answers
35
views
Are there conventions around naming entry point groups in Python?
Pytest uses the pytest11 entry point group to automatically discover plugins once they are installed, without the need of any manual configuration by the user.
You can see them via
import ...
0
votes
0
answers
92
views
Rust string manipulation, flow control improvements
I am new to the language and currently learning from the rust programming book.
I am wondering if there are any better way to improve my code. Especially the 2 pop (not sure if its the best practice)
...
1
vote
1
answer
378
views
What is the convention for naming C# files that contain extension methods? [closed]
While creating a library to learn C#, I've realized that there are a lot of conventions on how to name files, variables, parameters, interfaces, etc.
Now, I am making a file that will contain ...
0
votes
1
answer
222
views
Use case for np.log2 vs math.log2
Sometimes, authors use np.log2 instead of math.log2. For example, in this PyTorch code:
num_pools = int(np.log2(spatial))
(where spatial is a Python number)
Because math.log2 is a built-in an ...
0
votes
1
answer
102
views
Use branch prediction with no else statement
I am currently implementing selectionsort. Using the code below and the driver file to test it below. I am currently trying to do micro optimizations to see what speeds it up.
public static void ...
1
vote
2
answers
241
views
Is there a convention in the order of registers used to store values for calculations when using assembly language x86-64?
I know this question was submitted many times, but I couldn't find any clear answer yet, so I'm sorry, but I still have the doubt.
When programming in assembly language, for personal issues, not ...
1
vote
1
answer
87
views
Better practice for double or more line breaks in Rust? [closed]
I want double like breaks like below:
[ your title there ]
some kind of content...
In rust, there're two macros to print to stdin, one with like break and one with no like break.
And some possible ...
1
vote
1
answer
85
views
What is the point of using >| when redirecting to /dev/null? [closed]
I'm looking at a Bash file from the GitHub docs. Here's an excerpt:
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-...
0
votes
2
answers
180
views
do { } while(0) alternative in macro definition or any other possible options [duplicate]
I have encountered a way of making a multiline macro function definition in C/C++ compilation, that does not meet any clear code conventions (and possibly creates performance drawbacks?). Is it the ...
4
votes
2
answers
275
views
Is Using double variable type instead of float a bad habit [closed]
I have to code C for my college exams and I have practice of declaring double variables instead of float variables. Is it a bad habit? Can they deduct marks for it? (we never exceed the float limit)
I ...
0
votes
0
answers
70
views
HTML sourcemap convention
Per the Source Map spec §6.2:
There are two suggested ways to link source maps to the output. The first requires a server support to add a HTTP header and the second requires an annotation in the ...
0
votes
1
answer
67
views
Best practice: where should user prompt messages reside in Java classes - main or method class? [closed]
I'm creating a Java class with methods, setters, and getters. I have a createTrain method that prompts the user with a message like 'Create how many trains?' in the form of a string. Should this text ...
4
votes
1
answer
1k
views
Ways to represent float infinity in C++
I want to express floating-point infinity in C++ for my program.
I came across two ways to achieve this: using INFINITY and std::numeric_limits<float>::infinity().
Both options seem to work, but ...
0
votes
1
answer
60
views
GET for complex payload scenarios?
Our team is designing a RESTful API that strictly follows REST conventions. We are currently facing a challenging problem for which we have not yet found a solution. As you can see, the
...
0
votes
1
answer
206
views
Is it safe in general to use spaces between specific thickness values (e.g. Margin or Padding) in XAML elements?
Recently one of my colleagues started using spaces instead of commas as separators for specific values in Thickness fields like Margin and Padding:
<Label Margin="0 1 2 3"/>
While ...
0
votes
1
answer
1k
views
In sveltekit, what's the convention for splitting client side code between route files?
Both +page.js/ts and the <script><script/> tags within +page.svelte files are for processing client side code.
What's the typical convention for choosing between these 2 files?
0
votes
1
answer
33
views
Is there a convention for how to shape deeply nested ElasticSearch queries?
Very specifically, I am trying to generate an arbitrarily deeply nested ElasticSearch/OpenSearch query, and I was curious if there was 1) a convention for and 2) any performance ramifications for how ...
-2
votes
1
answer
1k
views
How to specify CSS media query breakpoints? [duplicate]
What is the right method to use CSS media queries?
Should I specify a breakpoint for each device size or write the queries according to when my website's shape starts to get bad? What is the ...
-2
votes
3
answers
211
views
How to identify a C-style string in C?
In C, a function may ask for or give a C-style string, or not. Or return it.
How to distinguish a C-style string from a non—C-style string? Is there an idiomatic common way to do this?
Maybe you could ...
2
votes
1
answer
1k
views
Is there any importance for indentation when breaking a line (using backslash or parenthesis) in python?
Is there any importance for indentation when breaking a line (using backslash or parentheses) in python? How about the style recommendation, which one is recommended? I tried to ask bing chat/chatGPT ...
0
votes
0
answers
41
views
Typescript definition file - for a function, return actual property types, or custom property type itself?
I'm trying to write a TypeScript type definitions file for an external JS library, MusicKit JS. I'm fairly new to TS (and especially declaring type definitions in TS). The MusicKit docs are, at times, ...
0
votes
1
answer
175
views
Is there a convention if GNU-like CLI should consider stdin or file passed as arg to come first?
I'm designing a CLI that should accept input in two ways:
From stdin: cat in_stdin.csv | csv2parquet -o out.parquet
From one or multiple files passed as explicit argument csv2parquet in1.csv in2.csv -...
0
votes
2
answers
430
views
Variable with same name as keyword
Is there a good way to create a variable, function, class, etc. with the same name as a keyword?
What I usually see (and follow myself) is using slightly different names. For example, using clazz or ...
1
vote
1
answer
440
views
What is the best practise for mybatis mapper xml files?
I'm a bit confused about mybatis mapper xml files.
Is it better to have each class in a separate mapper file like below:
<mappers>
<mapper resource="org/mybatis/builder/AuthorMapper....
0
votes
1
answer
1k
views
Why is it recommended to use multiple files when making a C++ project?
I'm Learning C++ and coming from GML which is pretty similar in syntax. But what I don't understand is why it's recommended to break up a project into multiple files and multiple types of files.
From ...
0
votes
0
answers
231
views
REST API support and naming for POSTing data as json or file upload
I have a REST API controller supporting the following:
IActionResult PostRows([FromBody] Rows[] body)
POST /api/v1/rows
with a JSON body, e.g. [{ id: 1}, { id: 2}]
I also just added a REST API ...
0
votes
0
answers
376
views
Can the usage of the UI Document (form the UI Toolkit) without a camera be considered a good practice in Unity?
I'm need a low resolution (pixelated) view for my game and am using a render texture, so the camera isn't rendering anything to the screen/game view. To bring the downscaled view to the player I'm ...
1
vote
1
answer
57
views
Is serial considered a keyword or a numeric type?
Here it is mentioned that, "the data types smallserial, serial and bigserial are not true types, but merely a notational convenience for creating unique identifier columns." Everywhere in ...
-1
votes
1
answer
115
views
Industry standards a self taught android developer should learn | Android studio, kotlin
I'm a self-taught android developer, I want to work as an android developer but I have some imposter syndrome. I think there should be coding conventions we should follow when we code, like:
Follow ...
5
votes
2
answers
748
views
Should you decorate dataclass subclasses if not making additional fields
If you don't add any more fields to your subclass is there a need to add the @dataclass decorator to it and would it do anything?
If there is no difference, which is the usual convention?
from ...
-1
votes
1
answer
84
views
is there a distinction between single prefixed underscore and double prefixed underscore in the C++ STL implementation?
I am asking this question for readability reasons not for implementation.
I haven't found any article explaining any distinction between single prefixed underscore and double prefixed underscore or ...
0
votes
0
answers
186
views
What's the point of unwrapping a single value from an array?
I've seen in a few apis where when an array value is expected, then when it's only one value the library/framework will unwrap it from its array and just send the single value.
What is the point of ...
1
vote
0
answers
111
views
Tests name convention best practices
Does anyone knows some good references to guide me in order to give automated tests, the best possible names? I know the rules but want good references to support some of the names that I used. Thanks ...
-2
votes
1
answer
168
views
Should comparison be implemented under `compare` or `operator ==` when both are needed?
In making a class, the compare method and the operator== overload should have identical functionality. Therefore, only one implementation is needed, and I'm trying to figure out if there's any reason ...
0
votes
1
answer
94
views
Python class, methods and conventions [duplicate]
Suppose Im creating a class named Bar:
class Bar:
def __init__(self, foo):
self.foo = foo
Once I create an object of Bar, How should I get the value of the foo variable?
Should I just ...
1
vote
0
answers
203
views
How to handle logging and imports when running a python module as the main script?
I have a python library/package that contains modules with functions & classes I usually import inside of my application's main script. However, these modules each contain their own 'main()' ...
0
votes
1
answer
377
views
How should I organize my update/draw logic when using requestAnimationFrame?
The JavaScript code for my HTML5 game has the following structure:
// <body onload="load()">
function load() {} // Load all images then call init()
function init() {} // Get all images ...
0
votes
1
answer
32
views
Why do maximum line lengths sometimes end with 9?
In some conventions, PEP-8 for example, I see maximum line widths recommended to be set to values ending with 9, such as 79, 99, 119. Why not rounded to 10, like 80, 100, 120?
I feel like it's an off-...
-2
votes
1
answer
69
views
Function naming convention when with qualifiers: adj+verb, verb+adv or adv+verb? [closed]
For example, for names comprehensiveInspect, inspectComprehensively, and comprehensivelyInspect, which to choose?
'inspectComprehensively' obeys syntax, but I have never seen a function name ending ...
0
votes
1
answer
90
views
C#: convention for synchronous method implementing an async interface
I have an interface that needs to be asynchronous. Most of the implementers of that interface will be asynchronous methods.
interface IValidator {
Task<bool> ValidateAsync();
}
However, one ...
0
votes
1
answer
250
views
Using Python's `unittest` module to compose tests of functions in a separate file
I have an issue with getting my unit tests to resolve calls to the S.U.T.'s functions. The S.U.T. is defined in a separate file, but in the same project. I've considerable Python experience, but I've ...
0
votes
1
answer
242
views
Why do most PyQt tutorials create classes from widgets?
TLDR why do people create classes (Window for example) when its only going to be used once?
Some examples:
RealPython, the first code block
PythonBasics, first code block
PythonPyQt, first code block
...
0
votes
1
answer
222
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://learn.microsoft.com/en-us/aspnet/core/razor-pages/razor-pages-conventions?view=aspnetcore-6....
1
vote
1
answer
193
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 ...