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
4
votes
0answers
36 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 ...
3
votes
1answer
7k 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 ...
5
votes
2answers
1k 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
6k 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
103 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
47 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 ...
11
votes
1answer
370 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
932 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 ...
5
votes
4answers
5k 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
582 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
127 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
493 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
179 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
194 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
2k 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
597 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
14 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?...
2
votes
1answer
11k 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
250 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
40 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 ...
2
votes
1answer
111 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'...
-5
votes
2answers
810 views

9 ways to generate Fibonacci numbers in C++

This is C++ code that consists of 9 different functions that generate Fibonacci numbers. Although all functions display same result, the emphasis is on practice to use different methods or ways. I ...
5
votes
3answers
1k views

6 ways to find maximum value in C++

This code is part of a project of N-ways to code for one particular task. In this case, this C++ code consists of 6 different functions to return a maximum value from an array of real numbers. Mainly ...
2
votes
0answers
61 views

Composing commands to control virtual machines

I created a function which takes some inputs and builds a specific set of strings. The function is working as intended, however I can't help thinking how ridiculous it looks every time I see it. I ...
5
votes
1answer
301 views

Flask Framework - user sign in

These functions are more or less the same. They are doing the sign in process for a flask application. A user is retrieved from a database (identified through email address) and the password is ...
1
vote
3answers
1k views

Merge sorted lists, removing duplicates

I want to merge two sorted lists of Integers but this is not the general mergesort case because the same number may appear in both lists. (However, each number can only appear once in a particular ...
4
votes
2answers
3k views

Semantic markup for card blocks

I'm using Bootstrap. I'm doing my best to work with more semantic markup and getting away from divitis. Several of these "card" blocks appear on a page, like this. Original: ...
17
votes
4answers
10k views

20 Ways to do Random Sampling

Here is a (small project) code for practicing Python, it comprises 20 variety of functions that each works to return \$n\$ random samples from a set of data. The code mostly uses the ...
12
votes
2answers
5k views

Parsing an email string

My program needs to parse an e-mail string. There are two possibilities to enter an e-mail-address. Either with the alias or without one, plain the e-mail-address. 1st possibity: ...
-3
votes
1answer
52 views

Difference between using WHERE and AND with ON in SQL [closed]

I have a Sql query ...
5
votes
1answer
92 views

Class to clean CSV data so that processed results can be written into a database

I am trying to figure out whether I am following best practices while passing arguments to functions. These are my class definitions (Please note, that I have just provided the high level ...
3
votes
1answer
214 views

Calculate change denominations 3

I am trying to refactor a large application to use more DDD principles as and when I get chance. I am concentrating on the very simple areas first. The app currently has a very simple Domain Service ...
1
vote
2answers
59 views

Linked lists of templated classes vs function ptr

I am designing a library for a hierarchical problem. At each stage of the hierarchy there are several "tools" at hand. If at a state N one tool succeeds, the solution is passed to the next (N+1) state....
0
votes
2answers
5k views

Remove all html special chars

Before saving the input from users in the database, I am using the below function to replace all HTML special chars. All my users will always be using the English Language. Option 1 ...
-1
votes
1answer
6k views

string null check/ trim [closed]

Minor question on String null check and trim. // given a function func() that might return either a string or null String func() { return " hello "; } ...
2
votes
3answers
111 views

Printing lines of “*” of various lengths

As a beginner, I tried a programming drill. The method gets an Enumerable that contains numbers specifying how many "*" to print on each line. ...
5
votes
1answer
595 views

Normalize a GSM short message text

I am working to improve this script, which should prepare a text to be sent as a GSM short message using only the GSM 7-bit character coding with Basic Character Set Extension. ...
1
vote
0answers
96 views

PDcurses wrapper module, with mvc or pimpl

I have been writing a library wrapper for pdcurses for a while and implemented each widget/class in it with the pimpl idiom, however I start to see that for large widgets it creates a god object and ...
3
votes
2answers
357 views

Colors for unvisted, visited and hovered/focused/active links

I've created a userscript for Tampermonkey to style unvisited links with blue color, visited links with violet color, and red for hovered/active/focused links. It was created primarily for my ...
1
vote
1answer
85 views

Transforming lists of products to boolean vectors

Task Inputs Lists of products stored in a CSV file, where each line represents the shopping list of a single client: Outputs A CSV file: Header: products names sorted by number of appearances in ...
3
votes
1answer
848 views

Find spiral 2D matrix (List of Lists) of ints in a clockwise spiral

I got this question during my interview with Microsoft. The question called 2D Snake. I'm wondering if my solution 1 passes the test, but if my solution 1 different from solution 2. Let's have ...
2
votes
2answers
75 views

Find the middle of the string

The follow code should correctly run the test cases at the bottom. It works correctly. I just don't feel like this is clearest way I could write it. A lot of the complexity comes from having to ...
0
votes
1answer
39 views

Selecting data from a table based on value in another table (SQL server)

I am using the northwind example database to brush up my SQL server skills. I want to select all the products ordered by the customer with the customer id 'Folko'. My idea is to join the Orders ...
1
vote
2answers
85 views

Performing a sum with Swift

I wrote the following in Swift to perform a sum: let total:Double = session.courses.reduce(0) { $0 + $1.totalPrice() } It's concise, it does the job but it does ...
1
vote
1answer
65 views

Setting Property Values Programmatically in a JSON Object

Through the lens of the SOLID principles, which one of the following makes the most sense? I want to ensure the approach I select keeps everything simple and maintainable as we add properties, modify ...
2
votes
0answers
6k views

Accessing child class variables from its parent class

Requirements The code should be able to call a parent method to read and modify child object variable that is referenced by a pointer inside the Child class. This code is to be run on an embedded ...
9
votes
5answers
290 views

Applying a string-identified effect on an image

Task: Given an image object and an effect identifier (string), apply the effect identified by the string on the image. The library of effects can grow as the program grows. Code 1: ...
3
votes
1answer
877 views

Find LCM of two numbers

The problem is to find LCM of two numbers. I have tried to solve the problem in two ways. First by using the LCM formula : LCM (a,b)= a*b/GCD(a,b). Second, by ...
7
votes
4answers
20k views

Sorting dates in this format (DD-MM-YYYY)

Is this the correct and an elegant way to sort the dates in the format (DD-MM-YYYY) in ascending order? ...
3
votes
1answer
180 views

OO and non-OO usage of Mysqli

I'm starting to learn the object oriented aspect of PHP. In this regard I made a small "exercise" of sorts "translating" one of my PHP functions into OO mode of PHP. I'm asking if there are there any ...

1
3 4
5
6 7
17