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
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 ...
5
votes
4answers
11k views

Return IEnumerable<KeyValuePair> from a private method; use Dictionary or anon. type?

Is it okay to return IEnumerable<KeyValuePair<string, string>> from a private method instead of returning a read-only dictionary? This allows for ...
0
votes
4answers
89 views

Java method refactoring: getting the file name or path

I have been learning about refactoring and I have this method that I'm wondering if I should split into two for code cleanness. First, the method as one, next the method split in two: Method not ...
0
votes
0answers
15 views

I would like get some feedback on my code in Flutter [closed]

As I said in the title, I would like to get some feedback on my code in Flutter. I am novice in programming. The project was: create a stacks list of cards that contains details and also can be ...
-1
votes
1answer
83 views

abstract base classes versus the curiously recurring template pattern [closed]

Background Apologies for "burying the lead." The questions are in the next section. In my application, the purpose of inheritance is to abstract away complicated logic in the base class template, so ...
3
votes
1answer
44 views

Maximum distance between space stations HackerRank

I am just working on Flatland Space Stations problem, and it is not seeming to be a tough question, but my algorithm lags in some aspects, since it solves majority of the test cases but fails for some....
2
votes
0answers
46 views

Why does my Clojure implementation of Conway's Game of Life run so much slower than my Java implementation?

I'm trying to learn Clojure coming from a Java background. I have written a simple implementation of Conway's game of life in both Clojure and Java, trying to keep the overall structure of the code as ...
1
vote
2answers
34 views

Copying List Elements To Another List And Changing Them

I'm a beginner python programmer..I recently started reading a python book called: "Python Crash Course, 2nd Edition: A Hands-On, Project-Based Introduction to Programming"...And I found an ...
6
votes
1answer
460 views

Recursive LinkedList. Which implementation is better and why?

class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None <...
4
votes
3answers
1k views

Leap year check in Haskell, using pattern matching or bind operator

One of the first Haskell puzzles on http://exercism.io/ is to implement a leap year check. I've done this twice. Using pattern matching: ...
2
votes
2answers
69 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: ...
6
votes
2answers
983 views

Python Class Coding Simplification

Main purpose of this code, Take some information for animal features Clasification of user input print those input into txt file My problem is that, I think coding of animal features takes too much ...
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
32 views

A simple animation in pygame

I'm following a tutorial into pygame. I realized the example code was written for the sake of being easy to understand. I wondered if I could 'improve' the code, with a focus on keeping the exact same ...
2
votes
1answer
47 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) ...
4
votes
2answers
60 views

Builder design pattern pass object

Good Morning This is a builder design pattern .. the builder problem is duplication so I want to know from an expert with explanation which is better on quality on this code: (1) ...
10
votes
4answers
806 views

Shuffling multiple iterators in order

I have a Python function w/ specified functionality, and two proposed approaches - which do you prefer, and why? (performance, simplicity, clarity, etc) (both use ...
6
votes
2answers
390 views

Implementing web scraping in a function and in a class

The goal of my code is to implement a web scraping routine to obtain the name and the price of a product. I want to put this routine separated from the main program file. Sample url to scrape: https://...
3
votes
0answers
47 views

Simple beginner Rust CLI file reader that prints to stdout

Q: Am I approaching writing idiomatic Rust code correctly? Hi CodeReview, I'm a beginner Rustacean coming from Python going through Rust books (The Rust Book, Rust in Action). A lot of the beginner ...
6
votes
1answer
160 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 ...
4
votes
1answer
45 views

Finding missing void keywords in C source code

I'm writing a bash script to search C source files and find the lines where I missed the void keyword (unlike in C++, in C, empty parameter lists have to be indicated with the void keyword). I read ...
0
votes
0answers
34 views

Report writing, do the formatting work on database or non-database language?

When report writing, sometimes getting the data you need can be quite straightforward in SQL, but getting the data in the exact format you'll need it in for the specific report can be quite tricky. It'...
23
votes
11answers
5k views

Find nth Fibonacci Number, using iteration and recursion

I'm a beginner programmer and I came upon this problem which is to find the n​th number in the Fibonacci series. I used to solve the problem using a for loop; ...
4
votes
2answers
136 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 ...
1
vote
1answer
80 views

Best practice to initialize instance variables for a POJO when values are null

I am using Java 8. I haven't found another question that fits mine exactly, and I've come across some conflicting information on best practices with what I'm trying to do. I'm creating a POJO which ...
2
votes
1answer
72 views

Simple BST implementation using C++ Struct

I am trying to implement DSs in C++ and this is BST insert and search functions. I tried in two different ways, please review and see if one is advantageous over other. With pointer to pointer ...
3
votes
1answer
147 views

Convenience function to save and load pickle objects

I want to come up with a simple convenience function to save and load pickle objects. A secondary objective is to simply execute the function without the above function. I have come up with two ...
2
votes
0answers
145 views

generic implementation approaches for a recursive function

Let's take the famous fibonacci problem as an example but this is a generic problem. Also, taking scala as the language as it's rather feature-rich. I want to know which solution you'd prefer. we all ...
10
votes
4answers
23k views

Split Collection to two list depend on criteria

Let's say I have a List contains numbers: 1,2,3,4,5,6,7,8,9 and I would like to split this to two lists: odd numbers even numbers So I can do this two ways: Solution 1: Create two methods: <...
6
votes
3answers
195 views

C# Event Manager without allocations

I'm using my own Action-based Event Manager for a while and looking for ways to improve it. Mainly it's used in game development, where excessive garbage generation can lead to severe consequences. ...
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. ...
0
votes
1answer
57 views

Schedule talks in tracks [closed]

Consider my simple business requirement as follows: There is a list of talks and they need to be scheduled in tracks. Each track has a morning session starting at 9am and an afternoon session ...
7
votes
3answers
553 views

C++/Opengl voxel renderer

I have tried going back to C++ after long time of mainly doing C#. I realize that the code is far from perfect, however I would really appreciate if someone could point of what exactly is wrong and ...
6
votes
1answer
432 views

Bubble sort algorithms and unittest in Python

I am quite new in Python and I am starting my journey with sorting algorithms, PEP8 and the Zen of Python. So far i wrote a post BubbleSort and I drew conclusions and followed the advices. I ...
1
vote
0answers
257 views

Median of three partitioning taking more time than standard quicksort in java

I implemented a standard quicksort and I have a project where I need to improve it. I am trying to make quicksort faster by implementing median of 3 partitioning. I copied codes from trusted ...
3
votes
2answers
61 views

Organise method flow

I have something like a shop. It is limited to a checkout page, which will send an email. Nothing big, but a nice thing to learn more OOP. Almost every time I develop new classes I am wondering how ...
5
votes
3answers
340 views

Ask the user a number between 2 and 20

Here is my attempt: ...
0
votes
2answers
72 views

Implementation of the Selection Sort Algorithm

I have tried to implement the Selection Sort Algorithm in two different ways, and I was just wondering if that is considered to be a valid implementation of that algorithm. Would that be also ...
1
vote
3answers
193 views

Comparing two simple distance calculating algorithms

Is the single method printMaxDistance_a or the two methods printMaxDistance_b AND ...
3
votes
1answer
177 views

Redirecting the web client after deleting an item

In my web-app, it is possible to delete an Item when visiting any of 4 different pages: the Show Item page the Edit Item page the List Items page the List Items in Room page If the visitor uses a ...
2
votes
2answers
64 views

Find the next empty column on a chessboard [closed]

I was playing around with the "eight queens" problem, just to see how I could use C++ algorithms to write less code. I figured out a way to find the next unused column using ...
5
votes
1answer
108 views
2
votes
3answers
130 views

MySQL/MariaDB Data extraction / String manipulation / “TopN” processing => Performance of C++ vs php vs python

EDIT1: Suspicion that mariadb++ is affecting my performance results compared to the raw "mariadb/mysql Connector-C"?? EDIT2: I did a barebones C-Only implementation and it comes in at 222ms vs the ...
5
votes
1answer
95 views

PHP OOP classes used for building web applications

The following classes are used for web development. And I was wondering if I'm implementing them correctly specially the Base class. This is a version 2.0 of the question the classes are as follows: ...
0
votes
0answers
106 views

Recursion on graphs - networkx VS adjacency lists with native lists, sets or numpy vectors ( python )

Hope someone can help me out in reviewing this code to make it faster. My goal is to create a graph recursively: query for a node and its neighbors from a db (not present here) add it and its ...
6
votes
2answers
102 views

OOP design for election board

I am trying to build an OOP design for an election system. A citizen can nominate themselves to be a contender. So all contenders are citizens. I was thinking of keeping the relation ship IS-A by ...
5
votes
1answer
140 views

Shoe shine shop model in Rust and C++ - Follow-up

I've just refactored my Rust and C++ code which simulates the shoeshine shop model from this question. What else can be improved? C++: ...
4
votes
1answer
78 views

Get sum of an array in 3 ways, for, while and recursive

So i was trying to find sum of an array using 3 ways in perl6 for while recursive (I know there are inbuilt perl6 functions for this) I want to know if there is a better way to do this or is this ...
5
votes
3answers
162 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: ...
3
votes
0answers
61 views

Resizable containers with VueJS

I reviewed the code in Resizable split DIVs Vue.js, suggesting that the OP use computed properties and bound styles to simplify the code (at least reducing the need to use ...

1
2 3 4 5
17