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.

Filter by
Sorted by
Tagged with
2 votes
1 answer
53 views

Handle circular import of subclasses types in abstract class

I am facing a circular import error when I define type aliases for the subclasses of an abstract class. This is an example of what I'm trying to achieve: #abstract_file_builder.py from abc import ABC,...
CarlosMorente's user avatar
0 votes
1 answer
28 views

cannot use object as interface value in argument to function: oject does not implement interface in golang [closed]

I was trying to implment strategy design pattern in golang. Currently, my code looks like this: package main import ( ca "github.com/Kieraya/test/test2/cache" "github.com/...
Aditya's user avatar
  • 29
-1 votes
0 answers
13 views

Could you guide me on a pathway to becoming a skilled coder? [closed]

As a first-year student juggling eight subjects, I aim to become a proficient full-stack developer. How much time should I dedicate to coding amidst my academic load, and how can I effectively manage ...
ANKIT KUMAR's user avatar
0 votes
0 answers
15 views

Find a generator polynomial and generator matrix of a triple error-correcting [15, 5] binary cyclic code

Find a generator polynomial and generator matrix of a triple error-correcting [15, 5] binary cyclic code. Here q=2,n=15andk=5. So,|T|=15−5=10. 2-cyclotomic cosets: C0 = {0},C1 = {1,2,4,8},C3 = {3,6,12,...
Shashank's user avatar
0 votes
1 answer
34 views

How to structurally write different configurations of code for different number of variables

I am calibrating a bunch of parameters using any method (not important). But the number of parameters I choose to calibrate will be varied (anywhere from 1 to 4). If I wanted to calibrate 4 parameters,...
Xerium's user avatar
  • 1
0 votes
1 answer
63 views

Choosing between 'var' and explicit type in C# - Which is preferred? [closed]

I'm working on a C# project and trying to understand the best practice regarding the use of var versus specifying the explicit type when declaring variables. I've noticed variations in coding styles ...
FallenOG's user avatar
0 votes
0 answers
13 views

Using the same fixers for a team (EditorConfig)

We want to have the same codestyle in a project for all developers. So we are using a shared .EditorConfig file. However, the decision which fixers are used in a Code Cleanup Profile seems to be ...
TheWho's user avatar
  • 485
-1 votes
0 answers
19 views

I'm having an issue with DPI scaling in python. With this line ctypes.windll.shcore.SetProcessDpiAwareness(1)

I need help with a program I'm making to transfer files to other devices. I will tell you know before I start.... I don't know how to code. :) this is all chatGPT coding. I understand how coding works ...
Bryce Sergent's user avatar
1 vote
2 answers
63 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 ...
J. A. Corbal's user avatar
0 votes
0 answers
36 views

Can we create a custom class to use it in module_drawer paramter in qr.make_image() method

I need a solution which takes input as either svg file or png file and. Based on that we need to change the pattern on qr code , let me provide the input and output for reference input:input will be ...
chandana's user avatar
1 vote
1 answer
58 views

configuring swagger in springboot aplc getting error

I am trying to configure swagger in my spring application getting this error: java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition....
Naveen Chowdary's user avatar
-3 votes
1 answer
25 views

Thingsboard professional

I'm nitin pandey, I want to know that how can I add the javaScript condition in alarm cards professional version of thingsboard. if the temperature level is high then it should be the RED background ...
Nitin Pandey's user avatar
0 votes
1 answer
59 views

How to generate JSON in Java with clean code

I have code like this: Map<String, Object> tempParam = new HashMap<>(); tempParam.put("custid", "123"); json = gson.toJson(tempParam); String keyParams = "schema;...
mr.Gondar's user avatar
0 votes
0 answers
75 views

How do I format C# code in VisualStudio to capitalize the first letter

When C# code style does not conform to the specification, using .editconfig only prompts. It cannot be automatically formatted. Use Ctr+K Ctr+D is not modified. Is there any shortcut to do this?
code-jar's user avatar
-1 votes
1 answer
51 views

Why are there no spaces on both sides of the equals sign in chunk headers of R Markdown templates?

In the R Markdown file that you get if you create e.g. a new R Markdown file in RStudio from the template there, you will see that parameter settings in the chunk headers are often written without ...
Patrick's user avatar
  • 851
1 vote
0 answers
68 views

Refactor validation with return if statement

I have lots of method and on each method I have to do a validation. Currently, my code look like this and it works fine. @Service public class UserService { @Autowired private UserValidation ...
Justin Xu's user avatar
4 votes
2 answers
141 views

Is "*this = {}" valid inside a member function for reset in CPP

Recently, I was unhappy to find that I often ended up reproducing the constructor's behavior every time I had to create a "reset" function for an object. Example: class Foo { int i; ...
cadam's user avatar
  • 41
0 votes
1 answer
374 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?
Mike Thrussell's user avatar
-1 votes
1 answer
33 views

When we use class methods as setter to input object

What principle are we violating if we use a method to update an input object's fields? An example: class Data { public int $someField = 0; // it's private with setSomeField method public int $...
NameX's user avatar
  • 59
-1 votes
2 answers
115 views

What are the common ways to distinguish between identifier of local variables and global variables?

I write a function with using same identifier for local variable and globel variable, as shown as following codes: def func(time_len, num_nodes): pass if __name__ == '__main__': time_len, ...
theabc50111's user avatar
1 vote
3 answers
76 views

How to implement the Open-Closed Principle in error handling for new error types?

In the given JavaScript code snippet, there are two functions - handleClientError and handleServerError - that handle client-side and server-side errors, respectively. The handleError function is used ...
Ahzam Ahmed's user avatar
1 vote
1 answer
288 views

Prettier config for intellij settings

On one of our frontend (react) repos we have code written for the past 2 years styled with default IntelliJ code-settings We would like to start using Prettier and not be coupled with 1 IDE, we see 2 ...
Eran's user avatar
  • 1,628
1 vote
2 answers
62 views

How to handle Python exceptions in a decent way?

I am developing an online service with python. Since it is an ONLINE service, I do not want the service down under any circumstances. So I add lots of try.. except... to make sure that if anything bad ...
Cino's user avatar
  • 83
0 votes
1 answer
16 views

Importing multiple functions from python

I want to import two functions from a module but the names are quite long so want to import them as abbreviations. I am trying something like this: from module import function1, function2 as fn1, fn2 ...
Supreet Agrawal's user avatar
0 votes
0 answers
20 views

Compilation error: call to 'HTTPClient::begin' declared with attribute error: obsolete API, use ::begin(WiFiClient, url) [duplicate]

I tried the coding for IOT Door open Notification using IFTTT by Sachin Bhangale with the esp8266. But when I upload the code i got an error. I already tried the one from (Error: call to '...
xyaw's user avatar
  • 1
0 votes
0 answers
46 views

Python Django Framework Error: Could Not Find 'My Tasks' in the h1 tag

I am new to coding in Django. I am creating a Django App called Tasks. My code within each of the following files will be included. I keep getting the error that 'Could not find 'My Tasks' in h1 tag'.....
Victor Marshall's user avatar
0 votes
0 answers
232 views

In Visual Studio 2022, how can I change the null check template?

I frequently apply null checks to my parameters when developing in C# (like any good developer should!). Because I can be lazy, I'd prefer to let Visual Studio add these for me, which it can. However, ...
Brian Kessler's user avatar
1 vote
2 answers
65 views

Should i abstract over AWS SDK?

I'm working with AWS SDK and was wondering if it is worth abstracting over it. By abstracting i mean: Creating a library where i would define interfaces for IQueue, IFileStorage, ... Creating ...
BodzioSamolot's user avatar
0 votes
2 answers
276 views

How to cover the await by try...catch blocks nicely?

This code is ugly, isn't it? import axios from 'axios'; async function f1() { try { const resp = await axios.get('http://www.randomnumberapi.com/api/v1.0/randomnumber'); return resp.data[0];...
Vova's user avatar
  • 1
0 votes
2 answers
161 views

Single line comments in Rust [closed]

I wanted to know what is the correct style for writing single line comments in Rust. https://doc.rust-lang.org/book/ch03-04-comments.html#:~:text=In%20Rust%2C%20the%20idiomatic%20comment,%23!%5B ...
Coder's user avatar
  • 1,493
1 vote
1 answer
122 views

In Prolog should one avoid to use the ";" operator?

When writing Prolog predicates with multiple choice points (equivalent to an if-then-else or a case-statement) is it better to write several different predicates with the same signature, separated by ...
Kim Mens's user avatar
  • 325
0 votes
1 answer
314 views

How to prevent image from moving up when keyboard open in react native?

I am using an image as background using ImageBackground in react native it works well but when the keyboard opens image moves up I tried different methods but it does not work. I tried to resize mode ...
Muhammad Ismail's user avatar
1 vote
1 answer
176 views

Split a long sub-expression in an f-string into multiple lines

I have a Python f-string containing one really long expression: my_string = f"some text {this + is + a + really + long + expression + because + it + contains + some + really + long + identifiers} ...
SeppJ's user avatar
  • 97
0 votes
1 answer
87 views

Hexagonal Architecture : how/where to merge 2 adapters in 1 entity

I'm currently trying to implement a simple Hexagonal Architecture (in Java but it shouldn't matter for my question). I made 3 modules at this moment : A "domain" module and 2 "adapters&...
Thomas KLING's user avatar
-1 votes
1 answer
81 views

How can I get an input by the user without using the printf statement?

That is my code above. I have to read in 10 strings input by the user but I cannot figure out how to read in the 10 strings and store them in an Array without having to print a statement saying "...
amarveer rehal's user avatar
1 vote
0 answers
42 views

How to automatically add comments when creating a CSS rule in PhpStorm/WebStorm

What I am trying to achieve is this: When creating a new CSS rule, add a series of comments, for instance: .class_name { /* Comment one */ /* Comment two */ /* Comment three */ /* and son ...
Klymax's user avatar
  • 60
3 votes
2 answers
1k views

How to format java code based on .editorConfig file?

In a maven project (backend java + frontend angular) I would like to add a coding style and format code automatically (many file types), with a git pre-commit hook for example or/and at compile time. ...
user2668735's user avatar
  • 1,067
0 votes
1 answer
94 views

What Listener, Transition and Scheduler do in Solid's internal API?

I'm reading Solid JS's source code, but I find that there's little comments from code. Solid is much simpler than React, but lots of comments can be found inside React's code. Why there is no comments ...
Willer Jonsam's user avatar
0 votes
2 answers
314 views

Is there a better way to create Splash/ Loading screen in tkinter GUI

Creating an automated Tkinter Gui dashboard and going to deploy it using pyinstaller(.exe) The application takes a lot of time to load. So I decided to add a loading screen / splash screen. I was ...
Harry's user avatar
  • 3
0 votes
0 answers
290 views

how to create a popup alert and take input in vscode Extension

I want these type of popup in vscode extension. But , I am not able to create it please help me on these. I am trying in vscode but menubar is opened in debug page not seprate pop up you can check ...
2020pgcaca65 Priyanshu_kumar_k's user avatar
-1 votes
1 answer
54 views

How to maintain enums (and adding new values) in a very large codebase

In a very large and old codebase, suppose we're using a database column status with enum values as NEW, IN_PROGRESS, COMPLETED, REJECTED. Now this status is used in multiple conditions in code like if ...
gaganshera's user avatar
  • 2,629
1 vote
1 answer
183 views

Are there good naming conventions to get around long variable names, without having to rely on comments for better readability? [closed]

Basically I always try my best to avoid comments whenever possible. I watched many videos from Uncle Bob and regarding the things he wants to express, there are many things I agree to. He once ...
Bratko's user avatar
  • 19
0 votes
1 answer
115 views

How to use a git filter to implement a local code style different from the repository style?

A few elements of the coding style of the project annoys me. For example, I prefer 80 character line length, I never want the condition and the statement on the same line for an if (for breakpoint ...
Matyas's user avatar
  • 644
0 votes
0 answers
58 views

PHP-CS and custom rules for multi-line if statements Boolean operator at the beginning of the line

Is there a way to add a custom rule for PHP-CS such that the CI pipeline would fail if the boolean operators are not at the beginning of the line through multi-line if statements? Right: if (isset($...
Mutatos's user avatar
  • 1,715
0 votes
0 answers
29 views

how to display 5 vertical lines in the background in a responsive way? then 3 in tablet mode and 2 in smartphone mode? with CSS

I want to do exactly as the background of this website: Stripe website The 5 vertical lines in the background are at equal distance, fixed at a width of 1300px and then adapting responsively to 800px (...
Etienne Fabre's user avatar
2 votes
0 answers
217 views

In a Visual Studio C# project, is it possible to enforce Microsoft Learn's Best Practice Naming convention for tests?

Microsoft Learn suggests the best way to name unit test methods is like Add_SingleNumber_ReturnsSameNumber. I would like to force project contributors to follow this convention, making it an error if ...
Brian Kessler's user avatar
0 votes
0 answers
46 views

bottom submit button is overlapping the bootstrap footer on the content page

I have the following code on the _layout.cshtml page: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" ...
rimi's user avatar
  • 672
0 votes
1 answer
14 views

Shoud I import the css directly into the html of a certain view?

I've been working in this personal project, in which there are multiple HTML(views) and CSS files. o far I've been importing all the CSS files into one global.css, and importing this global.css into ...
Luan Lima's user avatar
  • 111
0 votes
1 answer
26 views

Cleaner way to repeatedly call the same group of functions but with different parameters

Say you have code like this? int main () function1(); function2(2); function3(2); function1(); function2(5); function3(5); function1(); function2(9); function3(9); function1(); function2(3); ...
pj427's user avatar
  • 1

1
2 3 4 5
156