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
0answers
7 views

How to differentiate web fonts font-face font-weights?

What do you guys think: OPTION #1 (same font-face name and change font-weight) ...
13
votes
2answers
458 views

Get the encrypted payload from an unencrypted wrapper PDF document

This is code, written by our dev team, and SonarQube tells me that the Cognitive Complexity is too high: 21, and the current (default, out of the box) metric limit is 15. I've had a go at reducing the ...
0
votes
0answers
13 views

Polling an SFTP server to list files in a directory

When is it better to instantiate the sftp client globally vs inside a function as shown below? What considerations favor one method over the other? For a long ...
3
votes
0answers
48 views

Resolving Git conflicts with Javascript

Challenge: Resolve git conflict by resolveGitConflict(linesArray, resolveMode), where linesArray is an array of strings ...
0
votes
0answers
25 views

Store tweets to a local MongoDB server

I use NodeJS along with the MongoDB NodeJS Driver to store tweets into my local MongoDB server. In the following setup, mongos insertOne method gets invoked quite ...
5
votes
2answers
111 views

PHP classes with functions used for building a web application

The following class is set of functions I use for web development(examples below) and I was wondering how to structure it. Examples: ...
2
votes
0answers
21 views

Fast algorithms in Javascript for shortest path queries in directed unweighted graphs - follow-up

(See the previous iteration.) Now I have reworked my pathfinder program, and I ended up with this: ...
5
votes
1answer
85 views

Simple HttpClient usage for integration tests in .NET Core

I have this simple setup for a .NET Core project which is just a very basic HttpClient usage to do some simple integration tests to a RESTful API. For now the test project remains separated from the ...
1
vote
0answers
33 views

Checking for a values existence: slice iteration vs map lookups in Go [closed]

Assuming I have the following slice: mySlice := []string{"one", "two", "three"} and I want to know whether or not it contains a given string, say ...
3
votes
2answers
51 views

Tkinter Program to teach Arabic Part 2 - Proper use of Global Variables

In part one (Tkinter program to teach Arabic) I was asking for help to review the part of the program responsible for managing the main screens and links to all of the different lessons. From the ...
3
votes
1answer
51 views

Comparing algorithms to decode a String

I am writing a function to decode a string, which means performing a string transformation like 3e4f2e --> eeeffffee. I have ...
6
votes
2answers
73 views

Filtering a list of customers in Java based on three criteria

Let's assume that you need to filter customers based on 3 criteria: name tags assigned to customer customer's location For some reasons you have to do it directly in your program code, without ...
0
votes
1answer
59 views

Extract HTML tags and its content from a string [closed]

Goal I want to extract HTML tags and its content from a string. The content (input) is queried from WordPress database. Sample data (input) I extract this dummy data from my WordPress database: ...
5
votes
5answers
2k views

Least cost swapping in C++

I've made a solution for a problem which involves changing order of objects having some mass, so it costs a mass of an object A and a mass of an object B to make a swap. The program needs to read a ...
10
votes
4answers
3k views

Sum Square Difference, which way is more Pythonic?

I'm using python 3 and I am creating an algorithm to find the sum square difference for the first 100 (or 1 to x) natural numbers. This happens to be project euler problem 6 if anyone is wondering. I'...
3
votes
1answer
79 views

Deserialize with LINQ query code in PageModel or PageView

Today I do something like this, where I get, select and sort some data and pass it on to the view (which loads a partial view) as a list of custom objects Page model ...
1
vote
1answer
43 views

Emulating the pipe operator in javascript in a readable way

In this article I found this quite elegant looking Elixir code: ...
-1
votes
2answers
128 views

Union of two double arrays

I would like to merge two double arrays and remove from the result array approximately equal items. My two input arrays have ...
2
votes
1answer
76 views

Go functions to create a directory if it doesn't exist

Which of the 2 solutions is written better? Personally I prefer the one line method but it does make it slightly more difficult to debug. Is perhaps doing it the long way first then refactoring to ...
1
vote
1answer
33 views

Middlewares with Route definition or Routes with Middleware definition

I am currently working on an Node based Express application. I have found Express's middlewares approach quite pleasing however, we all run in scenarios where a certain route or routes don't need a ...
3
votes
1answer
68 views

UITableView allowing some kinds of requests to be deleted with swipe gestures

I have a tableview which shows a list of objects called Requests. It has 3 segments. Namely Accepted, Received and Sent. And the objects for each segment are in 3 arrays. I want to enable deleting ...
1
vote
1answer
47 views

Getting initial values of non-primitive types from another Javascript file? [closed]

I have a file where I keep some initial values for some form fields base on field type. Some of them are primitive values, like '' or 0 or false but some of them ...
2
votes
1answer
42 views

Searching for matching shares

We're working on some code that involves validating certain UNC paths (specifically looking for things that appear to be subdirectories of other things), and we've gone back and forth on how to best ...
12
votes
2answers
1k views

Calculating Fibonacci sequence in several different ways

I'm doing an experiment trying to freshen up my unit-testing and learn dynamic programming. Every test passes but I'm curious of the result of some of them and worried if I'm doing the testing ...
15
votes
2answers
2k views

Message-formatting code with pluralization, revised to be more functional

I'm a C++ dev, and I've recently started working my way through Clean Code*. Whenever I encounter an example I think I could improve, I try to re-implement it in C++. On pp. 28-29 there is an example ...
0
votes
1answer
52 views

Imperative and functional-programming solutions for Jumping on the Cloud challenge

Problem Statement Emma is playing a new mobile game that starts with consecutively numbered clouds. Some of the clouds are thunderheads and others are cumulus. She can jump on any cumulus cloud ...
8
votes
2answers
105 views

Function invocation every second time

Recently I got test task at the project, it is fairly simple: ...
4
votes
2answers
96 views

Displaying IP addresses in Go using Stringer interface

I am trying out some Go code examples (while coding a private project) to get more "in-depth" knowledge about the language. I have come across an exercise from the Go Tour website about displaying ...
0
votes
1answer
159 views

Adding a Node to the Linked List is taking a longer Time when using a reference to the Tail Node

I am trying to add two numbers in the form of linked List and return their result in a Linked List as given in https://leetcode.com/problems/add-two-numbers/ Question: You are given two non-empty ...
2
votes
3answers
135 views

Finding the next available filename [closed]

We're having a small debate in work about the following piece of code: ...
7
votes
1answer
99 views

Function to send email, refactored based on SOLID principles

I have the below method that is responsible for generating and sending a MailMessage using a SmtpClient object: ...
4
votes
1answer
50 views

Evaluating π using Monte Carlo methods - Serial vs OMP

I wrote this simple code for evaluating the π using Monte Carlo method. This is the serial version: ...
5
votes
1answer
126 views

Detecting the presence of multiple URL segments

I have two versions of a function that performs the same task, however I'm not sure which one to use. Speed is something to take into consideration, but I also want to know what the best practice is. ...
0
votes
1answer
75 views

One try with multiple catch blocks vs nested try

I am creating program which will parse .csv file and I am using FileReader and Scanner classes from java API. ...
3
votes
3answers
83 views

Find minimum value in a BST: using boolean operators, and using conditionals

I've been studying the BST code in Paul Graham's ANSI Common Lisp. He provides (my comments): ...
1
vote
1answer
120 views

Two solutions to 2-sum

I have written a solution for two sum problem in variation. first is simple with two loops and another one is one loop and hash map. But I wonder why the simple solution is faster than the efficent ...
2
votes
1answer
50 views

Nodejs functions to load and save RSA keys

I'm creating my first real life Nodejs project. I've created some files and all work, but I'm not satisfied about what my files look likes. It's unreadeble. For example, I work of a file to manage ...
5
votes
3answers
224 views

SkipLast of an IEnumerable<T> - Linq Extension

As my answer to this question, I came up with this solution: ...
3
votes
1answer
76 views

Pre-calculate the winning combinations for an n-sized tic tac toe board using C++ functional programming

This code pre-calculates the winning combinations for an n-sized tic tac toe board. I first created my function using an imperative approach. This is just how I naturally write code most of the time....
1
vote
1answer
36 views

Aspect-oriented vs explicit style in Python [closed]

Readability counts, but is very subjective. The following snippets are equivalent in functionality and turn a generator iterator into a chunked HTTP response in Flask. Which of those two patterns is ...
6
votes
1answer
813 views

Avoid using C Strings on C++ code to trim leading whitespace

I'm learning C++ and wrote a function to remove all the spaces and tabs at the beginning of the input string. It removes them until it find a character different of space and tabs. In the first ...
2
votes
1answer
37 views

Two ways to implement DND type abilities

I am creating a game in Java that uses the DND model for a lot of its components. I've hit a roadblock when it comes to creating and implementing abilities. I have ...
5
votes
1answer
89 views

EEPROM-based filesystem, aiming for Misra C++ 2008 compliance

I'm writing code for embedded systems (IAR compiler) and it should adhere to Misra C++ 2008. This limits the available features of the language quite a bit: no C++1x features use of the standard ...
2
votes
1answer
72 views

Fetching configuration or default value

I have two code snippets, doing exactly the same thing and both get the job done: use defaults use from config Which is cleaner to use in golang and why? first option: ...
4
votes
1answer
22 views

Showing a “back-to-top”-button after scrolling a certain amount

I have a "back to top"-button on the page, It should be visible after the user has scrolled a certain amount*. This means I have to add or remove a class active ...
3
votes
1answer
84 views

Most efficient way to check if user is allowed to update an object

So I have an user which can create his own Locations. I implemented a webservice in order to add and update locations. If the user is not the owner of the location i want to throw an appropriate ...
4
votes
1answer
104 views

Two ways of implementing a combat system

Below is a segment of a game I am writing to stay in practice with my Java. EDIT The class this method is in is the Encounter class. This class just manages the encounter between the player and an ...
3
votes
2answers
84 views

Optimizing Luhn check digit algorithm

The internet as a whole and Code Review in special already provide a decent amount of implementations of the Luhn check digit algorithm. They often follow a relatively "naive" strategy, in that they ...
0
votes
0answers
60 views

Merge Two Sorted Lists in JavaScript

The task is taken from LeetCode Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. ...
2
votes
1answer
53 views

Populating dropdown lists, using SQL vs. using expression trees and reflection

I'm working with a large enterprise SQL Server database with dozens of tables that are used mainly as lookups to populate dropdown lists, etc. These tables all follow the convention of having (table)...