Questions tagged [coding-style]
DO NOT USE! This tag refers to an entirely opinionated subject and is therefore no longer on-topic. Questions about coding style and conventions.
coding-style
7,788
questions
0
votes
0
answers
23
views
Which python logging style is recommended or standard? [closed]
I am new to python. Between the following 2 options. Which style is recommended or better for python ?
logging.info(f"Won't save model as score is below 0, score: {score}")
logging.info(&...
0
votes
0
answers
16
views
in vscode Autocompletion does not occur when manipulating the dome
const h1 = document.querySelector('#hi');
h1.styl = "red" --> not auto-completed
I would like to autocomplete style. Please tell me how to solve it.
I am aware that auto-completion is ...
0
votes
0
answers
17
views
Should I wrap indented comments at column 80, or extend it due to the indentation? [closed]
Question relating to code comment styling, but this should be language agnostic.
If I have a comment beginning on a deep indentation, do I still wrap it at column 80, or extend it to account for the ...
0
votes
2
answers
65
views
Avoid ifdef in my project for multiple hardware
I have a project written in C on STM32 platform. My project source code will be available for multiple hardware. I use CMakeLists
For example I have 2 header for the moment hardware1.h and hardware2....
0
votes
0
answers
54
views
Can I use yield as a variable name in Java 17 when yield is a reserved keyword?
I have an existing Java codebase where I use yield as a variable name. With the upgrade to Java 17, where yield has become a reserved keyword due to the new switch expression feature, I'm concerned ...
-4
votes
3
answers
58
views
Scope Variable inside Python's Try, Except block
At first, i wrote my simple code as below:
while True:
try:
x = int(input("what's x? "))
except ValueError:
print(f"x is not an integer!")
else:
...
0
votes
1
answer
38
views
How to manage multiple uses of a model in an application?
I'm currently implementing an application and have for example a Customer model that's used in several different parts of the application. Each part only uses a subset of the properties from the ...
-1
votes
1
answer
27
views
I want to add retry logic and. refactor the code in the python socket connect code
I have the below Python code which checks whether the ssh host is up or not:
`for hostname ,ipaddr in host_dict.items():
if tcp_conn.tcp_port_is_open(ipaddr, constants.TCP_PORT, ...
1
vote
1
answer
34
views
Can I create a default object in the constructor of a class in the dependency injection pattern?
I'm starting to develop a rest API in the MVC pattern using NodeJS and Typescript.
In my model layer I created entities, services and repositories.
My controller layer is decoupled from the framework ...
0
votes
0
answers
25
views
WebStorm imports from HTML
When I import from HTML a Enum/Const the protected readonly that WebStorm produces is at the bottom of the TS; Is there an option to set the protected readonly above the constructor?
Code example
HTML:...
-1
votes
1
answer
59
views
Best practice regarding code in constructor for initializing in C#? [closed]
I am learning C# and learning about classes, and I have a question regarding best practices in class initialization and constructors.
For instance, I was doing a practice exercise from Player's Guide ...
-2
votes
1
answer
36
views
Which of these is the best structure of a if-statement in a BlocListener for a SignIn? [closed]
I'm designing an application that uses Flutter Bloc and i'm not sure which of the two approaches is better in terms of structure. One is shorter in terms of lines of code, while the other is more ...
0
votes
0
answers
52
views
How to configure a linter (e.g. Ruff) to disallow double assignments in single lines in Python?
I'm looking for a way to configure a linter (such as Ruff or another popular Python linter) to disallow double assignments in single lines, like this:
name, position = files.name, pos
Instead, I want ...
0
votes
2
answers
56
views
How to reuse switch block labels without goto?
How to implement the following code without goto and unnecessary code complexity?
namespace Test
{
static class Program
{
bool keyA = false;
bool keyB = false;
// ...
...
0
votes
0
answers
19
views
Relationships of code style tools in .net
I am confused of diversity of tools for code style and analyzers. I do not know how to structure these concepts in mind like Roslyn, Roslynator, .editorconfig file, some .net packages like Microsoft....