730 questions
Advice
4 votes
14 replies
245 views
Is there any way to make this more neat?
I currently have a block of code looking like this: if (StateA) { DoSomething(); } else if (StateB) { DoSomething(); DoSomethingElse(); } I was thinking there must be an elegant way ...
-1 votes
1 answer
41 views
Need Help Improving Code Comments & Structure for Luau Role Application
I've applied for the Luau role on the HiddenDevs website five times, but I keep getting rejected. I'm feeling really frustrated and would love some guidance on how to overcome this obstacle. Each time,...
0 votes
0 answers
24 views
Context specification when linking functions in instances in AHK
Good day, I'm trying to improve my OOP competence and trying to create a code to generate a single window(gui) which hold n checkboxes based on the files the code finds in a specific folder. The idea ...
0 votes
2 answers
93 views
Tedious Type Casting when indexing Vectors in Rust
Im currently trying to optimize my code for readability and have run into issues when I'm indexing an array but also need to use negative number. Here's the example: Example Case Explanation since its ...
0 votes
2 answers
116 views
Ugly Triple Indirection: Extensible Buffer Management Struct [closed]
I'm currently trying to build a string parser for an AVR based stepper motor controller. The idea is to observe some input string over UART, then breaking apart this string into several sub-buffers ...
-2 votes
1 answer
57 views
Does adding too much validations for user inputs is a good practice while creating REST APIs [closed]
I'm building a REST api which take some inputs like id,customer_id,firstname,lastname,contact,email,updated_time,created_time. Before processing these inputs, i have added validations to check if id ...
1 vote
5 answers
155 views
Find the remaining Enum
I have the Enum A, B, C. In a method, I am given two different Enum and must return the remaining Enum. Example: I receive A and C I must return B The solution that I have is to use if elseif else: ...
0 votes
2 answers
350 views
TypeScript functions within functions vs. private functions [closed]
Here is a hypothetical example: I have a market.service.ts with 2 functions called buy() and sell() which are each 100 lines of code export class ShopService { public async buy() { // 100 lines ...
-1 votes
1 answer
246 views
Is there any difference between using "content = { }" parameter or directly "{}" in Jetpack Compose?
I was wondering if it is better to use directly "content = {}" parameter instead of "{}" despite I see more often people using "{}". Is the code cleaner or does the code ...
0 votes
1 answer
121 views
How do i use loop to name or use variables in Kotlin?
I'm trying to create a "pixel" layout and manage movements over there for an exercise, and I would love to know a simple/creative way to name and use all the variables without doing terribly ...
0 votes
2 answers
94 views
How to improve this program's readability?
I'm learning the basic of Python dictionaries and am having an exercise on nesting dictionaries in a list. It basically told me to make 3 dictionaries about 3 people, nest them inside a list, loop ...
-3 votes
2 answers
644 views
Python for loop: array unpacking vs range deconstruction
I'm following a data structures and algorithms course taught in Python at the moment and the instructor always opts to unpack arrays (well, lists) using a range functions (method 2 below) instead of ...
1 vote
2 answers
113 views
How to deal with constant error checking in C?
In C, I am calling many functions having to check if they worked. The code gets ~3x bigger because of it! An example: char *myStr = malloc(sizeof(char)); if (!myStr) return NULL; Is there a more ...
-1 votes
1 answer
519 views
How to make this Python function for finding colourful numbers operate on any number?
A colourful number is one that includes no duplicates in the list of it digits + the products of the subsets of its digits. For example, the products of 263 are [2, 6, 3, 2x6, 6x3, 2x6x3]. These are ...
0 votes
2 answers
592 views
ImportError: cannot import name 'legacy_round' from 'textstat.textstat'
I am trying to import legacy_round from textstat as follows: from textstat.textstat import textstatistics,legacy_round But I get following error: ImportError: cannot import name 'legacy_round' from '...