Skip to main content

Questions tagged [comparative-review]

This tag is used for questions which present a problem and multiple solutions, where the asker wishes to know which solution is best (and why).

Filter by
Sorted by
Tagged with
1 vote
0 answers
26 views

Making a shell around jointjs for react, wondering between two approaches

The React tutorial of joint js shows a way to use jointjs in react. The tutorial is quite limited: it is basically defining a special named div and putting all jointjs code inside. The jointjs ...
paul23's user avatar
  • 211
3 votes
1 answer
49 views

Better Microsoft SQL update

I've got the following SQL that I need to update by adding a new parameter: ...
jp2code's user avatar
  • 318
-1 votes
1 answer
98 views

Refactoring Agreement Status Logic: Applying SOLID Principles and Separating Logging/Auditing with Decorators

I have some production code that contains a lot of repetition and mixes business logic with auditing and logging. I've made two attempts at refactoring it, primarily using decorators. I'd like to get ...
KJanek's user avatar
  • 121
3 votes
2 answers
85 views

Generic ring-buffer

What would be the preferred C way of implementing a simple generic ring-buffer. Which approach from the 2 below (or even some 3rd) would you use and why? Specifically, this will be part of an embedded ...
user1806687's user avatar
3 votes
0 answers
91 views

Comparing two Tree sort algorithm variations implemented in Java

I have this repository. It contains three variations of a simple sorting algorithm for integer keys. The idea is that we keep a balanced BST in which each node holds the integer key and its frequency. ...
coderodde's user avatar
  • 29.8k
3 votes
2 answers
702 views

More Square Root

This is a follow up question to my Studies on Square Roots post. I'm posting additional code for solving for square root similar to the other, but with more code to benchmark. ...
user avatar
8 votes
4 answers
909 views

Studies on Square Roots

This post marks the beginning of my ventures into calculating square roots. However, I have no idea how the processor, more specifically the FPU with the fsqrt ...
user avatar
1 vote
1 answer
48 views

Send a QNetworkRequest with a parameter

I want to send multiple QNetworkRequests in Python 3.12 that each downloads one image from a server, using a single callback function. To be able to distinguish ...
Neph's user avatar
  • 131
2 votes
3 answers
709 views

Capture multiple errors before raising an exception

I have a scenario where I need to store values from some environment variables (names of which I cannot control). My first run at this was pretty basic, however this is not usable as an exception ...
David Gard's user avatar
3 votes
1 answer
92 views

How to avoid null Values in a .NET 6+ ASP.NET project [closed]

I'm currently exploring multiple options to get rid of null values in my .net web api applications. Let's say, that we have the following Project: ...
szuuuken's user avatar
  • 131
3 votes
2 answers
79 views

Reading a file into lines (benchmarking getline() vs mmap_memchr() vs mmap_getline() vs fread())

This is a follow-up to: Reading a file into lines with mmap vs getline. The actual names of the functions are not ...
Harith's user avatar
  • 9,777
7 votes
1 answer
246 views

Reading a file into lines with mmap vs getline

I required a function to read a file into lines for a text editor, and ended up with two routines. One uses getline(), and the other uses ...
Harith's user avatar
  • 9,777
3 votes
1 answer
101 views

Simple C++ event loop - static vs dynamic dispatch performance

I have two extremely simple toy implementations of an event loop, and would like to understand the performance differences between them. First impl - events with a virtual 'handle' method - dynamic ...
Jnuk's user avatar
  • 33
3 votes
1 answer
48 views

Comparing a set of parameters contained in two separate strings in Powershell

I have a situation where I need to compare two strings with each other in a foreach loop that potentially run over millions of rows of data. The two strings will always contain between 1 and 12 ...
Tanaka Saito's user avatar
7 votes
2 answers
284 views

Subtract two lap times (m:ss:fff)

I have two lap time strings I need to subtract, the format is minutes, seconds, milliseconds. This is to compare a new world record time to the previous holder's ...
Soda Party's user avatar
5 votes
1 answer
214 views

Compute the mean of a series of user-entered numbers

Which is more elegant out of two methods as mentioned below mostly from memory prospective? Both methods achieve the same result, but from a memory perspective, In Method1, we are storing the running ...
Karn Kumar's user avatar
1 vote
3 answers
150 views

Count number of clients that have subscriptions

I have two working solutions, one using an accessor (getSubscription()) and one using a member variable (subscription). Which ...
user avatar
11 votes
2 answers
940 views

Leap Year Calculator Using If Elif and Else Only

I'm taking the 100 Days of Code (Python) taught by Angela Yu on Udemy. There have been a few other questions revolving around this lesson but I can't find one who came up with my specific question so ...
AGM's user avatar
  • 113
6 votes
3 answers
622 views

Implementing a --assume-yes/--assume-no command line flag to affect a `input()` based `confirm()` function

I have a Python command line application that needs to ask the user for confirmation at some point. I want to add a --assume-yes/...
Lucas's user avatar
  • 161
1 vote
0 answers
67 views

Combined or separate data-cleaning routine

I am a junior data engineer that have 3 years of experience with Python. I write a lot of Python code for my job and I came up with this question I can't solve by my own. I don't have the chance to ...
Izem's user avatar
  • 11
2 votes
1 answer
50 views

Comparison of Named parameters and the Java Builder pattern in C++

OK writing a C++ wrapper on top of openSSL. Setting up the SSL_CTX* object. There are a whole bunch of extra functions to specify functionality on how this object ...
Loki Astari's user avatar
  • 96.6k
3 votes
1 answer
54 views

maxlist(L, M) that succeeds if M is the max number in the list L

I'm working my way through "Prolog For Artificial Intelligence" by Ivan Bratko, and exercise 3.17 is to write a maxlist(L, M) that succeeds when ...
Avrohom Yisroel's user avatar
1 vote
0 answers
60 views

Revised: best practice of communicating with an instrument using Python

This is a revised version of the code from the previous question. It corrects the spelling errors, add in appropriate comments for argument types and doc strings, rewrite number representation, and ...
cloud chang's user avatar
3 votes
1 answer
290 views

Best practice of communicating with instruments using Python [closed]

I have seen two different methods - getter and setter method and property - being used in Python libraries which are written for communicating with instruments via VISA commands. An example is given ...
cloud chang's user avatar
4 votes
1 answer
109 views

Spring REST Endpoint for Saving a User Inquiry

Here's a piece of code from codebase I maintain/contribute to. It is a Spring REST controller, which exposes an endpoint to create user question. The question consists of title, description and ...
Sergey's user avatar
  • 617
5 votes
1 answer
115 views

Instance specific code generation

Disclaimer: I've asked this question before on Stack overflow and got a response that this place would be a better fit so I am copy pasting the question here. I've come up with two different ...
user1806687's user avatar
3 votes
0 answers
38 views

TestAssignment class that checks for certain Git repository conditions

TestAssignment is a Python class designed to check certain conditions in a Git repository. It has several methods that check for the existence of required files, the initialization of a Git repository,...
Beki's user avatar
  • 31
2 votes
1 answer
118 views

Logger that can be redirected to switch off output

I am evaluating two implementations of a C++ logging mechanism. The first implementation, below, unconditionally streams (calls the insertion operator) to the ...
StoneThrow's user avatar
2 votes
3 answers
108 views

Wordlist formatter code

I am making a "wordlist cleaner" module that loads a words.txt file, and returns a list of cleaned/sorted words. Full code: ...
angel's user avatar
  • 35
1 vote
1 answer
209 views

Excluding attributes entirely vs. setting them to None

I am making a program that parses profiles from a website. Some profiles are "public" and others are "private" with limited information. Public profiles contain a lot more data and ...
angel's user avatar
  • 35
1 vote
0 answers
136 views

Making Robert Tarjan's offline LCA algorithm run (much) faster (Java)

I have produced this GitHub repository that compares the performance of: Robert Tarjan's off-line lowest common ancestors algorithm, An improvement of the above algorithm. Typical demo program ...
coderodde's user avatar
  • 29.8k
7 votes
6 answers
1k views

Compute "negative" version of vector of vectors

Given a std::vector<std::vector<double>> (e.g., representing some points in a space with D dimensions), I want to ...
Filippo Bistaffa's user avatar
3 votes
1 answer
146 views

rust sort numbered directories (non-lexicographical)

I am very new to rust and have been reading up and playing around to get a better understanding. I was trying to replicate a small task that I have done via bash scripting before, as a way to ...
Kyle Price's user avatar
3 votes
1 answer
80 views

calculating the percentage of distribution of ids per Loc for each country

Which of the two queries is theoretically better and why? I would like to understand why query 2 takes longer although there is no relevant information in the Execution Plan. I'm querying a Presto ...
Pin_Eipol's user avatar
3 votes
3 answers
103 views

Parse program arguments of the form key=value

I have two proposals for parsing arguments: Method A ...
alirezaarzehgar's user avatar
0 votes
1 answer
181 views

Getting three numbers input interactively and process them

I'm new to Python and programming in general. Let's imagine I have a simple task: Given 3 numbers from user input, I need to count negative ones and print the result. Considering what I know about ...
QLEDHDTV's user avatar
0 votes
2 answers
461 views

Functional Style if/else in java

I would like to ask the opinion for experts out there. The following code snippet was written by a colleague of mine who is very fond of functional style in Java. ...
office.aizaz's user avatar
2 votes
1 answer
162 views

C/C++ hash looking in flat database compared to PHP

I have a hash table which I would like to query as fast as possible. The hash table is stored this way : When I query a hash, I extract first 4 characters then use it to find the file. For instance a ...
James's user avatar
  • 41
3 votes
2 answers
932 views

Convert Rankine temperatures to Celsius

I have this Python Package called ToTemp under development for precise Temperature Conversions and currently thinking in changing the method's implementation to be ...
eddyxide's user avatar
  • 141
1 vote
2 answers
115 views

Circular list vs. doubly-linked list: which is faster?

In this post, I will compare performance of a circular list and a conventional list with head/tail -references: ...
coderodde's user avatar
  • 29.8k
5 votes
2 answers
666 views

Recursively calculating powers by squaring

Consider the following function that implements optimised O(log n) exponentiation by squaring: ...
saxbophone's user avatar
4 votes
1 answer
167 views

Array Implementation In JavaScript

Review I have written my own implementation of Array in JavaScript with the basic functionalities. Can anyone please review this code and point out the mistakes/how to make the implementation better? ...
enigma6174's user avatar
0 votes
1 answer
72 views

Comparison of two ways of looping in Python [closed]

I wrote a small script to demonstrate two ways of looping in Python: with and without using the index. I want to know which way is better. Please see the example: ...
Jeremy's user avatar
  • 111
2 votes
1 answer
87 views

Build a message string depending on the type of signature of an invoice

The following method was meant to build a message depending on the type of signature of an invoice. It contains some if-else statements and code duplication. The original method : ...
l0r3nz4cc10's user avatar
1 vote
1 answer
57 views

Comparing a weak fluent API with a strong fluent API in Java [closed]

I have this simple POJO: ...
coderodde's user avatar
  • 29.8k
2 votes
4 answers
1k views

Calculate the median value of combining two sorted lists

I have solved a leetcode problem (Median of Two Sorted Arrays), and I came up with two solutions. Solution 1 ...
111's user avatar
  • 45
2 votes
2 answers
120 views

Project sequence to multiple sequences using LINQ (or extension methods)

I'm creating a method that expands a sequence. This is a sample of how it works: Input: {1, 2, 3} Output: {1}, {1, 2}, {1,2,3} So far, I've been able to solve the ...
SuperJMN's user avatar
  • 233
2 votes
1 answer
154 views

LeetCode#494 target sum (dart is slower than python)

I'm trying to solve a LeetCode problem target-sum, in two languages: Python & Dart. The difference of time taken is shocking for me" Python took ~70ms while Dart took ~900ms !! Why does Dart ...
Abhishek Patil's user avatar
1 vote
1 answer
98 views

Selection algorithms (order statistic) in Java: linear time vs. sorting selector vs. Quickselect

This post is about computing order statistics: given an array \$A\$ (not necessarily sorted), find the \$k\$th smallest array component. The entire repository is here. ...
coderodde's user avatar
  • 29.8k
2 votes
1 answer
158 views

Card game simulations, with a multithreaded version slower than the single-threaded one

I'm new to rust and I'm trying to build a card game simulation to find all of the best actions with all possible hands. This requires a lot of simulations and my first 3 million are already taking a ...
PaulEliaz's user avatar

1
2 3 4 5
19