Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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).

0
votes
0answers
31 views

Choosing between types of Function Transformers : Sklearn Pipelines [closed]

I've recently started looking into pipelines to clean up my code. I would like to know which one of the following is the "better" approach when using Pipelines with Function Transformers and the ...
2
votes
1answer
28 views

PHP Factory Pattern : Should I use `create()` or `__invoke()`?

I currently had a colleague reviewing my code and he had a comment on a factory class I created. It's very simple: ...
1
vote
1answer
44 views

Longest Collatz sequence in Scala

I am trying to find the longest Collatz Sequence: Which starting number, ≤ N, produces the longest chain? If many possible such numbers are there print the maximum one. (1 ≤ N ≤ 5×106) I tried ...
10
votes
1answer
74 views

Counting times a file was committed to Git

A long time ago I implemented some code to walk the git commit graph. I recently updated the accompanying analytics part of the code base to follow file moves/renames in order to get a more accurate ...
1
vote
1answer
41 views

Classic “100 doors” simulation in Clojure

I read this question about the "100 Doors" puzzle, and thought that it would make for a good quick exercise. I ended up with two implementations. The first is more straightforward and uses a vector ...
2
votes
2answers
52 views

Image resizing in Rust

Are there Rust features I could apply to optimize for simple test of a JPEG or PNG resized from 2000 x 2000 pixels to 150 x 150 pixels? ...
8
votes
3answers
294 views

Processing player's move in an ASCII rogue-like game

I'm making an ASCII roguelike game and while writing the code for processing the player's move I can't decide between these two options. I have defined a class named ...
1
vote
1answer
23 views

JS/Node.js .env loader

I needed an environment values loader for a random node project, and instead of just using dotenv, decided to just make one myself and see how it'll turn out. To make this meaningful, here's a rough ...
5
votes
2answers
697 views

Remove the first value for a doubly linked list

You need to remove the first element which contains a given value from a doubly linked list. I created two solutions since I find the edge case of removing the first element to be problematic. So I ...
2
votes
1answer
165 views

n choose k combination in JavaScript

I was asked to solve a problem for \$\binom{n}{k}\$. I did the following implementation and am wondering if there's any feedback. Input: n = Integer ...
1
vote
0answers
47 views

Message loop handler functions, using associative array and using switch

I am using the Windows API to register system-wide hotkeys. This requires a message loop to be created, and a handler to handle the hotkey messages. I have written two pieces of functioning code. The ...
3
votes
3answers
81 views

String comparator as a lambda

I am writing a Comparator for my TreeMap. It looks like this: ...
-2
votes
1answer
59 views

Forward call to method depending on runtime type [closed]

I'm currently trying to build a in-memory read model on application startup. Therefor I use an event store that returns the event data as json. In my read model class there are handler methods for ...
7
votes
4answers
371 views

reinterpret_cast vs bit shifts for extracting 32-bit integers from bytes, with either endianness [closed]

I've written some simple helper functions that read data types from a vector of bytes (binary files) and having a tough time deciding which route to go. Method 1 : reinterpret_cast ...
4
votes
2answers
71 views

Assigning several variables from request URL using regexes

I refactored some of my code: Summary: This implementation works with PSGI/Plack. It gets the URL from $env->{PATH_INFO} and assigns a different variable ...
-1
votes
1answer
47 views

Check Unique Chars in A String

Two solutions to check if a String contains unique characters. Wanted to know if these solutions can be optimized further. The Code: ...
5
votes
1answer
85 views

Reading a config file in python

We're wanting to read data in from a config file and provide it to other python modules in a helpful way. We have found a number of ways to accomplish this that range from the module being easy to ...
3
votes
1answer
52 views

PHP function to evaluate comparisons between two values, with debug logging

The following method works fine but it is rather verbose: ...
1
vote
3answers
77 views

Given a series of characters from stdin, print their squared integer ASCII counterparts

This program in essence is extremely simple, however, it can be written in many different ways. I'm a beginner at C and I've written it in 5 different variations (mostly differing in the use of ...
4
votes
2answers
77 views

ASP.NET HTML code generation, two approaches

I was asked to give more context. So here we go. We want to create some HTML in code behind to add an "add" and a "refresh" button to a grid view header column. Approach #1 does this using string ...
2
votes
2answers
350 views

String Swap-case one-liners (6 ways)

I did this small project where there are six one-liner anonymous methods that can swap case of a given string of any length. For example "heLLo, woRLd" ==> "HEllO, WOrlD". I used this string as the ...
4
votes
1answer
60 views

Three versions of a counting-up timer in JavaScript

I made 3 versions of a counting-up timer in JavaScript: Version #1 All units of time (seconds, minutes, hours, and days) are updated every second, whether they change or not. Pro: Shorter code. ...
4
votes
0answers
96 views

Parallel solutions to N Queens Puzzle

I'm trying to increase the performance of my N Queens Puzzle solution. I'd find some threads on SO already but they don't appear to help me to increase performance. My best solution, however, is a ...
3
votes
3answers
77 views

Transforming XML with null checks vs variables

I'm working on an Spring Integration application that transforms a XML (converted by Jaxb) into a custom Object by checking various information given in the XML. The problem is that I can't trust ...
0
votes
1answer
143 views

Refactoring a class / map of query parameters that are passed between layers

There is an interface: interface JournalCreator { @Async Journal create(Parameters params); } And many different implementations: ...
0
votes
0answers
24 views

Processing RabbitMQ messages with Processors from another system / Interface Segregation

I was reviewing a app that runs as a service and processes messages form RabbitMQ. The app processes the messages using Processors retrieved from another system. ...
0
votes
0answers
32 views

Dispatching calls to user-selected tests

In my codebase I often create structs containing const char* and std::function. In doing so, I can then put these ...
0
votes
0answers
71 views

RGB to HSV image conversion with CUDA, with branching and branchless versions

I have created two CUDA kernels for converting a 3 channel 16-bit RGB image to a 3 channel 16-bit HSV image. The first kernel below performs the usual algorithm in a fairly straight forward manner as ...
3
votes
0answers
29 views

Validating a collection of proxy servers with maximum possible throughput

I am validating a collection of proxy servers and trying to achieve the maximum possible throughput. I've tested a few different methods, such as Task.WhenAll, TPL ...
2
votes
1answer
443 views

Substring vs Split performance test

Some people are telling me that using string.Split is very inefficient since it creates a lot of arrays in the heap. So, what are the alternatives if its real? The challenge? Taking a large string ...
3
votes
2answers
213 views

Python Find the N adjacent digits in the 1000-digit number that have the greatest product

This question was presented to me, adapted from Project Euler #8. The goal is to find the N adjacent digits in the 1000-digit number that have the greatest product. Range of N: 10 <= N <= 50. ...
5
votes
1answer
636 views

MessageFormat.format() with named parameters

I was looking for how to use MessageFormat.format() in Java with named parameters, as a similar option exists in Python, and found this question. Some functions are ...
6
votes
1answer
93 views

Two versions of PDF-Selector

I have basically ended up with 2 versions of a PDF-Selector. Both versions do the same thing. I'm not sure which solution is better. Maybe someone could give me a code review. I use: PDFSharp-Nuget-...
0
votes
1answer
44 views

Null checking a generic type [closed]

Assuming I have a method with this signature public void DoStuffWith<T>(T foo) and I want to allow both structs and classes to be passed as ...
10
votes
0answers
150 views

Testing a list of proxies for validity concurrently

I have a class that tests a list of proxies for validity concurrently, which I have created in 2 different ways, one utilizing Parallel.ForEach and the other using a TPL Dataflow ActionBlock. I am ...
6
votes
2answers
256 views

Counting ambiguous Morse Code encodings, with and without Java Streams

Unique Morse Code Words International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ...
4
votes
4answers
658 views

LeetCode “Jewels and Stones”: counting certain characters in a string

LeetCode "Jewels and Stones" You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. ...
4
votes
3answers
528 views

Sub that compares 2 columns fast

This is an answer to this SO question: Vba comparing 2 columns of data. In that question the OP code is very slow (also not working properly but the problem is fixed) I spent some time to ...
1
vote
1answer
88 views

Translating a Haskell data to Python

I've been working on a project in python, and I needed to represent a certain numeric type. I need to represent the concept of some or all. Then I need to be able to add these amounts. Coming to ...
4
votes
3answers
416 views

Using an offset variable to keep track of the next item in a Rust array

I am using an offset variable to track the iteration position, and modifying / returning it. Is the below considered bad practice in Rust? I ask this because I don'...
7
votes
1answer
69 views

Counting occurrences of “A…Z” substrings

I'm trying to write code in the simplest and cleanest way possible. I've found a few ways to shorten and simplify my code through functions that I've never seen before or through using other methods. ...
2
votes
2answers
105 views

Click-through rate calculator using jQuery

I created a calculator for CTR with jQuery. The calculator is working just the way I want, but I'm quite new to jQuery and I wonder if I am using jQuery effectively. The goal of the code is that if ...
3
votes
1answer
137 views

JavaScript Blackjack game

I am learning javascript with the course Javascript Getting started by Mark Zaymota. Currently the code is in a script.js file, and I was wondering how could we refactor it to extract classes from it....
3
votes
1answer
565 views

XML design for parsing in C# [closed]

I am trying to design XML with configuration info so I can parse it into this code: ...
0
votes
0answers
12 views

Hiding and repositioning some elements for some WordPress posts

I have to gather a few posts (a Wordpress site) and I need to hide some elements and move some others. There are 2 simple ways to do this, which one of these is better if there is a better one and why?...
0
votes
1answer
867 views

onChange vs onKeyPress for input in React

I have an input form, and when you press enter I want it to call a function. I was wondering what "the right" way of doing this is. Right now I have an input looking like this: ...
3
votes
1answer
49 views

Trigonometric Subplots with Matplotlib

The code consists of 4 functions that result in a figure with 3 subplots: a sine wave a cosine wave and the superposition of both (a bichromatic wave). I have shown in 4 ways, the first two are ...
1
vote
0answers
33 views

Fetching student and teacher data from a given date range

I have two APIs which fetch data of teachers and students from a given date range. I am using forkJoin to get both APIresponse and display the data with a regular interval of 10 ms. This is working ...
1
vote
1answer
80 views

Monad Transformers

I've run into the same scenario involving Monad Transformers a few times now, and I'm looking for some "best-practice" advice. Bear with the introduction, the issue itself is really simple: Say you'...
0
votes
0answers
26 views

Comparison of element display action performed via JS or CSS (from an accessibility perspective)

While cleaning the code for a website I'm developing, I came up to a widget that is displayed on the sidebar of 2 pages, and that consists of a small tab system (4-5 tabs) that shows/hides small ...