Code Review Weekly Newsletter

Code Review newsletter

Top new questions this week:

Better way to code these deeply nested / multiple if/else statements

I have coded this mess of JavaScript and a bit of jQuery. Everything here works perfect as intended, however it is a real mess. What would be the best way to clean this up with best practices and …

javascript jquery  
asked by Josh Kirkpatrick 20 votes
answered by Matt Giltaji 34 votes

Using 503 page when my site is in maintenance mode

This is my code for 503 page: header.php if(getOption('maintence_mode')==1) { header("location:503.php"); exit; } 503.php <?php $protocol = "HTTP/1.0"; if ( "HTTP/1.1" == …

php  
asked by Prakash 16 votes
answered by Madara Uchiha 30 votes

Using Java 8 parallel streams

I'm trying to get more familiar with the new Java 8 features, so I am rewriting one of my earlier projects. It includes a class that keeps track of the best entry seen so far: import java.util.List; …

java concurrency stream java-8  
asked by Mangara 15 votes
answered by rolfl 11 votes

Avoiding Python multiline string indentation

I want to make this code: def usage(): print( """ Usage examples: Test deployment: $ fab [noinput] test deploy Staging deployment: $ fab [noinput] staging deploy …

python strings  
asked by noisy 14 votes
answered by jonrsharpe 20 votes

Random name-picker with array

I created a program that picks a champion for a role on the game League of Legends using arrays and random numbers. Is there a quicker and more efficient way of doing this? There is one form that …

c# array random  
asked by freebol96 13 votes
answered by AlexD 12 votes

Vector-to-direction method in Java

I don't really have a problem, but my code bothers me, because I know it could be done in a much better way. I have an enum of 4 directions: north west, north east, south east and south west. And I …

java enum  
asked by Vapid Linus 13 votes
answered by Simon André Forsberg 7 votes

Thread pool worker implementation

As an exercise in using C++11 features I decided to make a thread pool class. I would like to have a review on the code with focus on: Standards compliance / Portability issues / Best practices …

c++ c++11 thread-safety reinventing-the-wheel  
asked by Emily L. 12 votes
answered by Nobody 8 votes

Greatest hits from previous weeks:

Merge Sort in C++

I've written this code for a merge sort, which is meant to implement the pseudo-code from Cormen's Introduction to Algorithms: #include <iostream> #include <cstdlib> using namespace std; …

c++ sorting mergesort  
asked by Chiffa 3 votes
answered by Loki Astari 6 votes

Removing duplicate values from an array

Here is my code for removing duplicated values from an array. I think I tested it with the most possible cases. Any suggestions or bugs? public static int[] removeDuplicates(int[] arr){ int …

java array  
asked by ashur 11 votes
answered by morgano 7 votes

Can you answer these?

Creating a "Produce and Consume" using Swingworkers

I am experimenting with the produce and consume concept while trying to incorporate it into my own project. I basically have two Workers in a small example I made: ProduceWorker: Populates a list …

java optimization performance multithreading  
asked by Sillicon Touch 1 vote

Extending the MVC Routecollection

I'm currently developping an MVC framework on which I will be writing my websites. This is done through the usage of a starter kit. In standard MVC, your routes are registered like the following: …

c# mvc asp.net-mvc-4  
asked by Complexity 1 vote

MVC Model validation callback

I have made a simple MVC framework of my own for my personal website to learn a thing or two about how this whole thing even works. I think I've got the idea, but there's one thing I'm not sure about. …

php mvc validation callback closure  
asked by user2374794 4 votes
Subscribe to more Stack Exchange newsletters


Unsubscribe from this newsletter or change your email preferences by visiting your subscriptions page on stackexchange.com.

Questions? Comments? Let us know on our feedback site. If you no longer want to receive mail from Stack Exchange, unsubscribe from all stackexchange.com emails.

Stack Exchange, Inc. 110 William St, 28th Floor, NY NY 10038 <3