Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
75 views

This is going to be a bit hard to explain, but I'll try nevertheless: So, I'm a novice trying to turn a Kahoot Generator I made into a library to share on GitHub. After thinking about how I wanted the ...
Jediweirdo's user avatar
5 votes
2 answers
115 views

I have a class that looks like this template<class T, class THash, class TEqual, class TCompare> class GraphT { public: typedef NodeT<T, THash, TEqual, TCompare> NodeInt; typedef ...
raaj's user avatar
  • 3,489
-2 votes
1 answer
80 views

How can I save a file with the name as: oldname+"_new"+extension in an elegant way? I currently do: ext = os.path.splitext(file)[1] output_file = (root+'/'+ os.path.splitext(file)[0]+"...
thestruggleisreal's user avatar
1 vote
1 answer
110 views

Consider the following two code snippets (assumed to be inside an async function that returns void / we don't care about the return value): Long version (without await): if (condition) { ...
Vipul Naik's user avatar
-1 votes
1 answer
78 views

This is a code of my function, I had to breakdown the main function into subfunctions. When I tested the main function it worked but not when I tried to print the output of subfunction. I tried to ...
user23203518's user avatar
0 votes
2 answers
133 views

I have a code logic as below: // Option 1 try { String result = x.getResult(); if (result == null) { // some handling logger.error("xxx"); } } catch (Throwable t) { // ...
eriee's user avatar
  • 396
0 votes
0 answers
61 views

I created a mini app which shows the Continent & the Country selections. just to practice RxJS concepts. (You can checkout to ng-conf/learn-rxjs-01 branch on https://stackblitz.com/edit/stackblitz-...
Angular animal's user avatar
1 vote
1 answer
1k views

I just scaffolded a project using Template Studio WinUI v5.3 and when I press Ctrl K D to format document, the getter and setter is placed on new lines. current.cs public class MyClass { public ...
Mihai Socaciu's user avatar
-2 votes
1 answer
160 views

How many times have you encountered a function with a return statement deep within the code? Or failed to notice a break or a continue in a loop? While I have not been blindsided by return recently, I ...
user2150648's user avatar
0 votes
0 answers
85 views

Edit: Changed bools to const bool, Added argument to anotherValueTest. May have oversimplified it before. I am using a MSP430 and the integrated Compiler from the IAR Workbench. Link to workbench ...
kremerf's user avatar
  • 31
-1 votes
4 answers
133 views

Instead of having two different loops that have identical printf statements, you can make a for loop that uses a boolean and ternaries to switch it forward or backward. Why is this bad form? Because ...
Daniel's user avatar
  • 17
-1 votes
1 answer
64 views

I'm programming Human Resource data sync batch program. This program reads user and department data from customer company's database and save to our database. For example, there is class named 'User' ...
Companion Cube's user avatar
1 vote
1 answer
101 views

Is there a simple way to format a string of a dictionary? I have a dictionary that I want to save into a file, to do this I am passing it to the file as a string using str(dictionary). This means that ...
superdupersolly's user avatar
-2 votes
3 answers
143 views

Code def addition(num): if num: return num + addition(num - 1) else: return 0 res = addition(10) print(res) Explanation I know what the function is doing: it is a recursive ...
Rozita Ghasemi's user avatar
0 votes
1 answer
330 views

function calculateTotal(items) { let total = 0; for (let i = 0; i < items.length; i++) { if (items[i].type === "food") { total += items[i].price * 1.1; } else { ...
Godsfavour Ozekhome's user avatar
-1 votes
1 answer
51 views

I know Java does not have pre-processor, but I struggle to find a way to do this. I am looking to create macros to improve code readibility, to specify which of the functions or parameters are for ...
IlluSion's user avatar
0 votes
1 answer
466 views

Without realizing it I've switched to the first block of code as a preference. I am curious if it is a best practice or more efficient to use the first block of code over the second or vice versa? In ...
Taylor MacDonald's user avatar
0 votes
1 answer
98 views

I was going through this Javascript tutorial when I came across a call for “one line – one action”. alert( 2 * counter++ ); Though technically okay, such notation usually makes code less readable. ...
hallofren's user avatar
  • 121
1 vote
4 answers
3k views

In rust I sometimes need to write chained if-else statements. They are not the nicest way to manage multiple conditionals with multiple things to check in the conditions. Here is an artificial rust-...
Juve's user avatar
  • 10.9k
0 votes
1 answer
217 views

New programmer here. I need to write a program using dynamic arrays to simulate an election. The program should first ask for a number of candidates, then take the candidate names and the number of ...
huntr_gathr's user avatar
0 votes
1 answer
139 views

I’m a one-man band that has developed a SaaS offering for an existing clientele of ~60k. I am a self-taught guy, starting with my Tandy 2500XL. And have worked on enterprise projects with a team since ...
JohnnyK's user avatar
  • 103
0 votes
1 answer
122 views

First of all I do not know if these types of questions are appropriate in stackoverflow. I have the following dict: file_dict = {"asda_20221003:ada":1, "scdfws_20221104eaf2we":5, &...
david.t_92's user avatar
  • 2,051
2 votes
1 answer
2k views

VBA excel: Is there any way to indent code for full module/script in VBA at once? It's ctrl+I in matlab and everything has the correct identation...
babipsylon's user avatar
-1 votes
1 answer
217 views

I used Macros at top of class to tell what is 1 and 45.00 instead of just writing magic numbers. Question is why using Macros in following class (see the default constructor) is not a good idea? Why ...
codingnoobs's user avatar
1 vote
3 answers
152 views

I have written this function to convert a vector of maps into string. There is a second map called field-name-to-columns which contains a mapping between the field-name and the actual name of columns ...
Razz's user avatar
  • 15
1 vote
2 answers
3k views

Most people when declaring strings in C++, or most other languages, do it like so: std::string example = "example"; However I've seen some code samples where it is done like this: std::...
ConnoisseurOfCookies's user avatar
1 vote
0 answers
62 views

I have the following function in Swift and am looking to improve the readability: Adding the variables to the Array below all of the let variables seems kind of funky to me and I was thinking maybe it ...
Dylon Jaynes's user avatar
0 votes
2 answers
200 views

I have this simple code which i have reduced to as little lines and made as readable as possible. I feel i did a good job but was wandering if it is possible to reduce down further? Any help would be ...
Junaid Razaq's user avatar
-1 votes
2 answers
121 views

is it possible to shorten these three for loops into one the code works absolutely fine, I just want to know if there is a possibility to shorten these three for loops into one for exercising reasons ...
the Lorde's user avatar
2 votes
1 answer
508 views

I'm using the cv::HoughCircles() function from OpenCV to detect circles in an image. The function takes an output parameter of type cv::OutputArray to provide the results. Based on the example code I ...
oliver's user avatar
  • 6,890
0 votes
1 answer
124 views

So i'm having a hard time with handling a large amount of class properties. Im making a "component" and want to make this "component" as customizable as possible. In doing so, I ...
user13020816's user avatar
0 votes
1 answer
1k views

Please help reduce the cyclomatic complexity of this method. I don't really understand how this can be done, I need all the conditions in this method and obviously there are no duplicates. private ...
Valeriy K.'s user avatar
  • 2,914
2 votes
2 answers
347 views

I have multiple service classes ServiceTest1, ServiceTest2, SeviceTest3 I have a factory class UserFactory, which creates a new User instance on every request UserFactory has a method createUser() ...
MrRobot9's user avatar
  • 2,744
0 votes
1 answer
261 views

Looking for a reference to a good reading or sharing an experience of what is better from the code readability/maintenance/best-practice perspective. There are two options on how to assign values to ...
Lock-o-motiffe's user avatar
1 vote
1 answer
37 views

Given two lists a=[(1,11), (2,22), (3,33)] and b=[111, 222, 333] I would like to know if there is a syntactically easy-to-read solution to iterate over triples of values as follows: for x,y,z in ...
flonk's user avatar
  • 3,916
2 votes
2 answers
213 views

Currently, I am writing a laravel application with a part for sending messages between the staff at the company and the clients. So, I have a field named "status" in the database. In this ...
ZOHREH's user avatar
  • 37
-1 votes
1 answer
46 views

Hi I wonder if there is a better way in terms of code readability and repetition. I have a large file that do not fit in memory. The file is either compressed .gz or not. If it is compressed I need to ...
RomainL.'s user avatar
  • 1,014
0 votes
2 answers
122 views

With the following code, how could I improve its readability using reflection and generics? It's a lot of repeated code, but I'm new to these concepts. "dl" is an interface but I'm not sure ...
Mark Jonh's user avatar
1 vote
1 answer
193 views

I just started working with thrift and created following thrift interface. map<string, map<string, string>> getInformationByIds(1: set<string> Ids) As you can see, the return type ...
Isuru Herath's user avatar
0 votes
1 answer
65 views

I had a datastructure as a numpy array. Python accessing a data structure Instead, I see I can get it as a panda dataframe. To write readable code, I'd like to address the data in the values column (...
havarsak's user avatar
1 vote
5 answers
133 views

I need to find minimal date(year , month , day, hours , minutes , seconds), my code is working, but it look's terrible and it's very long. What can I do to avoid this ladder to make my code readable? (...
user avatar
0 votes
4 answers
109 views

How to go about reusing my js code without just copying it and changing the names of variables? I want to add more questions but reuse the same code? This is a simple web test/quiz. CURRENT CODE ...
DozerDog's user avatar
0 votes
1 answer
2k views

What is the most readable way of writing a very simple function that is effectively executing one statement, if a condition is met? What I find most readable is this: function doSomething(myNumber){ ...
Subler's user avatar
  • 657
0 votes
1 answer
39 views

Is there any short form for writing MySQL CASE statements as in PHP switch? For example, if i have: SELECT CASE Type WHEN 1 THEN "A" WHEN 5 THEN "B" ...
Masoud Shariati's user avatar
0 votes
1 answer
109 views

Which way is better? Or do you know more better way? data = Hash.new { |h, k| h[k] = Hash.new { |h2, k2| h2[k2] = [] } } # 5 or more times or def object_in_hash(&object) Hash.new { |h, k| ...
Kodai's user avatar
  • 1
-1 votes
4 answers
2k views

How to wrap this expression in java for more readability with the constraint that the sub expression (shouldSendSomething(x) && loooongFunctionName1(x) && looooongFunctionName2(x)) ...
Athul T R's user avatar
1 vote
1 answer
254 views

I have some function that does one thing for 5 cases that conveniently have the values 1 to 5 and something else for the other cases. The possible values come from an API that currently has ~100 ...
Gregarious Git's user avatar
0 votes
0 answers
117 views

Is there a programming language that is purely written left to right? Example (close to Python syntax): Normal Python: a: int = 2 + 3 Left to Right Python: 2 + 3 = a: int The assignment should be ...
Semmel's user avatar
  • 575
0 votes
1 answer
54 views

I have a vector of text, e.g. library(stringi) MWE <- stri_rand_strings(200, 10, pattern = "[A-Za-z0-9]") My actual example is not random, so I get to find some recurring occurences of ...
Anthony Martin's user avatar
0 votes
3 answers
1k views

I need to ignore null parameters in the where clause so that i can fetch the appropriate data with the applied filters from the user side. Inorder to acheive this, I am currently using the if..else ...
Thameem's user avatar
  • 756

1
2 3 4 5
7