209 questions
Advice
0
votes
9
replies
142
views
Pythonic way to obtain dictionary keys with desired property
In python 3.12 I have a dictionary of which the keys are 2-tuples of integers and of which the values are integers (as in the function f:N × N → N for which f(n, m) = n + m). What I need is those keys ...
1
vote
0
answers
80
views
Pythonic Dependency Injection
I would like to ask if there is a Pythonic way to do dependency injection. I know that most of the ansewrs will be depending on the project. Therefore, let's put a clear example:
I am trying to ...
0
votes
2
answers
107
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....
-1
votes
1
answer
57
views
Function definition compiled inside .h file, but not on .cpp file, using C++17 and VS code
I was trying to implement in a .cpp file the definition of setColor(), which was correctly compiled before within the .h file from Sphere class, but now I get the next linker error:
Starting build...
...
1
vote
1
answer
305
views
How to fold subroutines in VScode?
How to fold subroutines in VScode? I am reading Fortran code in VScode, which contain the main program and many subroutines. The VScode can also fold codes but seem randomly. How to make VScode ...
2
votes
1
answer
312
views
How to thread, pipe or compose functions in lua?
What to do in lua if I want to pass a value to foo(), pass it's return to bar(), pass it's return to baz() etc?
Exhibit A (pseudocode):
backwards(code(reading(like(not(do(I))))))
Exhibit B (...
1
vote
1
answer
97
views
What is the idiomatic way to handle third party dependencies in .NET and C# that are provided as dlls
Let's consider that I have a .NET project and that I have to use a library that is not provided through NuGet but as a dll.
folder tree:
-> SLN
-> Project 1
-> Project 2
Let's say ...
0
votes
0
answers
60
views
How should I structure code/files to avoid repeating time consuming calls to build a data structure?
I am working on a word puzzle game solver that needs to determine whether or not some candidate word is valid. I am storing all of the valid words in a trie data structure, after they have been loaded ...
0
votes
1
answer
194
views
Should I check the type of input to my class properties?
I am a fairly new developer in Python and was getting accustomed to the idea of "Duck Typing".
I have a class I used in another module to do particular things with it, for example, access it'...
0
votes
0
answers
248
views
How to Create Subapps in Nuxt. and Create Modular Deployment
I am creating a Nuxt.js frontend/Express backend environment that will house multiple "sub" applications, for instance the structure currently looks like -
\-APP
\--Backend
\---public
\---...
-1
votes
2
answers
363
views
Best Practice for handling & naming intermediate/temporal variables in C# [closed]
In my C# (.Net 6) backend (but also in other languages) I often face the problem, that I get an object which I need to validate and convert before using it. Currently I handle this by creating two ...
1
vote
0
answers
51
views
Structure Policy for Django / Python Libraries
Question Summary
Hi Folks,
This is a kind of opinion question, I've built a Django library for my company and I keep swithering and changing my mind on how to structure it.
Possible strategies I've ...
0
votes
1
answer
132
views
How do I organize my javascript code instead of nesting callbacks?
I'm making a application in javascript (Nodejs), I'm kinda new to it. My code needs to do multiple congruent requests, I organized my code in async functions so I can linearly call them
my first code ...
7
votes
1
answer
2k
views
How to use a local Swift Package which provides two libraries?
I have a local swift package Foo which provides two different libraries Foo and FooB. Now I would like to use them in another local package Bar. I am only able to get the whole package by path ...
1
vote
2
answers
107
views
What is wrong in this c# code for simple RestApi?
I received feedback:
"code test is not at the expected level there's a lack of understanding of async, HTTP clients, and just software development patterns in general. Poor structure and testing&...
-1
votes
1
answer
674
views
Unity c#: Code-structure or how to access a method/variable from another class/script?
I have two classes: Menu_Buttons, in which there are definitions for methods executed on clicking different buttons in the menu, and PauseMenu, which defines what happens when the Menu key is pressed ...
0
votes
1
answer
89
views
Improve reusability of my data transformation functions
I have currently done with my code transformation on my api data by its roleId.
However, I need to display another view which will group the data according to which projectId the users are in.
I can ...
7
votes
4
answers
1k
views
Writing style to prevent string concatenation in a list of strings
Suppose I have a list/tuple of strings,
COLOURS = [
"White",
"Black",
"Red"
"Green",
"Blue"
]
for c in COLOURS:
# rest of the ...
0
votes
2
answers
89
views
In what ways could this React code be improved?
I am brand new to React and only semi familiar with JS. I starting making an application using React/Flask/Mongodb, but I am getting tripped up on some of the best way to structure my function calls/...
0
votes
1
answer
147
views
How to best find code implementations in existing python projects
Different people have told me that in order to improve my Python programming skills, it helps to go and look how existing projects are implemented. But I am struggeling a bit to navigate through the ...
0
votes
1
answer
161
views
How to structure my own Python signal processing module?
I want to take my Python (currently Version 3.9.7) programming skills to a next level. Up to now I just wrote some small scripts for myself, that no one hat to review or reuse. Now, I want to write ...
0
votes
1
answer
492
views
best practices in passing data with props in react
I have a problem with the structure of my project and i wanted to know what is the best way to solve my problem. I have three components and two level of nesting:
my grand parent component:
function ...
-1
votes
1
answer
163
views
How to name variables and structure code in dynamically typed languages for better readability? [closed]
Debugging old code in dynamically typed languages like Python, Ruby, JavaScript, etc. is often a struggle. For example, below Ruby function extracts only the key:val pairs from the result (hash) if a ...
2
votes
0
answers
866
views
Visual Studio 2022 - Object browser or Class view for TypeScript?
I'm new to TypeScript and starting development in React/TypeScript in Visual Studio 2022.
Is there any tool or extension that could be used to visually browse the structure of TypeScript project or ...
1
vote
2
answers
360
views
Is there an algorithm, to find values of a polynomial with big integers, quickly without loops?
For example, if I want to find
1085912312763120759250776993188102125849391224162 = a^9+b^9+c^9+d
the code needs to brings
a=3456
b=78525
c=217423
d=215478
I do not need specific values, only that they ...
-1
votes
1
answer
98
views
Link conventions
There are multiple ways of declaring a link with a title or without. I'm wondering whether there is a preferred way of doing it, either official or widely used in the community.
Taken from ...
0
votes
1
answer
153
views
Structure for pin declarations
I'm wondering how I should structure my code for the pin declarations of my MCP23017 (an I/O expander microchip) and whether I should put that in a function or not.
So currently I got the below script ...
2
votes
1
answer
359
views
Should layers be visualized in the code structure?
After have read Clean Architecture by Uncle Bob i have been thinking about the concept of screaming architecture and the last chapter around organizing code.
I have generally liked working with layers ...
0
votes
1
answer
133
views
Question about python code structure, functions and calling functions
I tried to create a function that does the following things.
(dont know if its worth mentioning but this function is invoked by another function)
connects to aws resources using boto3
gets a the ...
-2
votes
2
answers
889
views
Destructure a for loop
The problem set :
Letter combinations of a phone
The solution I had in mind:
def letterCombinations(self, digits: str) -> List[str]:
if not digits: return []
digit_map = {'2': 'abc', '3': '...
0
votes
0
answers
152
views
Easy access helper for JSON.parse in ruby?
To convert any object into a JSON, we have foo.to_json helper in ruby which returns a string. Similarly, to convert it back to its original datatype, we have to use JSON.parse(json_string), which does ...
1
vote
1
answer
1k
views
Creating a timed loop inside Discord Bot script to reload web page (web scraper bot)
I'm currently designing a discord bot that scrapes a web page that is constantly updating for patches related to a PBE server. I have the bot running through Heroku successfully right now. The issue ...
0
votes
0
answers
114
views
Dart: Use mixin to outsource implementations for abstract methods
my Goal is to structure my code with this. The Idea is to outsource an inplementation to elsewhere, so that your main class is not so overloaded with way to much methods. Mixins seamed to be perfect ...
0
votes
1
answer
77
views
Multiple Sliders Repeating Myself in Code
I have kind of a mess in my code.
In a parameter tab there are three sliders and maybe in the future there can be even more sliders.
let slider1 = document.getElementById("hello_interval_input&...
0
votes
2
answers
138
views
How can I structure code accordingly (in headers and source files) so I don't get compiler and linker errors?
I am currently doing the exercices in Bjarne Stroustup "Programming Principles and Practice Using C++" and I finished the 8th chapter, where he talks about headers and namespaces. Using this ...
2
votes
1
answer
5k
views
Pytest can't find files/modules
I have had a look at several different topics on this matter but can't work out how to apply it to my situation. I don't have an init.py in my test folder and I have tried to use conftest. I have a ...
1
vote
1
answer
56
views
Eliminating .then() blocks for a better code structure in JavaScript
For better structure of my script I want to eliminate .then() blocks. I.E. turn
callAsyncFunction().then( (result) => {
console.log("done");
callAnotherAsyncFunction().then( (...
4
votes
4
answers
790
views
Java - Getter/Setter, behavior and Interfaces
I have a question, a little bit theoretical:
Assume, I have the following classes :
interface ReportInterface {
void execute();
}
class Report implements ReportInterface {
private final ...
2
votes
1
answer
1k
views
How to split out and rename code files in git while preserving history?
I am new to git and now facing a git repo 'housekeeping' challenge after deciding to clean up the code structure. There are two dimensions to my challenge:
Need to rename suboptimally titled REPO, ...
0
votes
1
answer
316
views
Implementing layered architecture in DDD
For my software design class we were tasked to make a piece of software that would be designed using Domain driven design. My team and I chose to make a web app where coaches can input statistical ...
0
votes
1
answer
1k
views
source_files in podspec when source code is organized into nested group folders
Under my framework directory, I have the codes organized into groups like-
myFramework- (git repository root folder)
.git
LICENSE
README.md
myFramework -
...
0
votes
3
answers
248
views
C++ automatic finalization or objects destruction
In this example I faced the problem of copying the code:
void BadExample1() {
if (!Initialize1())
return;
if (!Initialize2()) {
Finalize1();
return;
}
if (!Initialize3()) {
...
0
votes
1
answer
41
views
How to format algebric code for readability
I have a fairly complex-looking (about 50 chars when typed out) equation that is all basic algebra (*, /, +, -, ^). How would I best style it for readability?
Condensed, it looks difficult to read and ...
1
vote
2
answers
273
views
How do I correctly reference to code in a different project in C#?
In short: I have a console application with a static Dictionaries, which work fine in the project they were written in. How do I reference to this project correctly, so that I can do the same from a ...
1
vote
1
answer
2k
views
set new value for array's value using destructure
i got two noob questions about destructure an array:
1st question: when destructuring an object, I can define a new value or a new key or both. On array, can I add a new value without add a new key?
...
1
vote
1
answer
802
views
Is Javascript LBYL or EAFP? [closed]
There are two programming approaches: EAFP (Easier to Ask Forgiveness than Permission) and LBYL (Look Before You Leap). First approach presumes doing something that can cause an exception, then ...
1
vote
0
answers
254
views
Destructure inside sort method javascript
I wrote a module that has sorting methods. I also tried to make it more flexible and destructure parameters to sort anything i will set creating object (more or less) but I don't know how to do it ...
0
votes
1
answer
578
views
Simplifying long CSS selectors
I have the following CSS selector:
#AllContextMenus :not(.menu-iconic-left):not(.menu-accel):not(.menu-accel-left):not(.menu-accel-container):not(.menu-accel-container-left):not(.menu-iconic-accel):...
1
vote
3
answers
588
views
How to import other source code files in dm script
Is there a way to use multiple code files in dm-script to structure the code? Something like:
import "path/to/utility_functions.s";
utility_functions.do_something_general();
Note that I do not want ...
0
votes
1
answer
218
views
How to use pep8speaks to check the code style/structure of my project
Reading the instructions here:
https://pep8speaks.com/
and here:
https://github.com/OrkoHunter/pep8speaks?installation_id=6398017&setup_action=update#configuration
I am a bit confused on how to ...