Code Review Weekly Newsletter

Code Review newsletter

Top new questions this week:

Find min of 3 numbers hardcoded

public static int min(int a, int b, int c) { int result = 0 ; if( a < b && a < c && b < c) result = a ; else if( a < b && a < c && b > c) …

java conditions  
asked by ERJAN 18 votes
answered by Simon André Forsberg 40 votes

Average time to first answer

Just trying out my T-SQL foo. Wrote a script to get the average time (in seconds) to first answer for a specified language. -- Could not get this so that the user entered -- the language in a box at …

sql datetime t-sql stackexchange  
asked by Loki Astari 18 votes
answered by rolfl 14 votes

Console application for providing detailed error messages

I'm writing a console application where I need to provide detailed error messages in case anything goes wrong. As a result of this, I find myself splitting up my code into many pieces and making sure …

c# console error-handling  
asked by soren.qvist 13 votes
answered by Pimgd 11 votes

Using C# properties for simple operations, where should I draw the line?

Should I be putting Linq statements inside of an objects properties? Is that a best practice or is that a no no? Also if that is ok, where do I draw the line with this? I assume db access is …

c# linq properties  
asked by DeadlyChambers 12 votes
answered by Olorin71 13 votes

Efficiency of this constantly running time processor for an HTML5 video control bar

I built a custom HTML5 video control bar, and for each second, it updates two readings: Time Elapsed Time Remaining in hh:mm:ss notation, like so: Because of how often this function runs, I …

javascript optimization  
asked by jt0dd 12 votes
answered by Dagg 13 votes

Is this a fast implementation of reversing a string?

I thought of this algorithm today. It seems fast, but how can I know? #include <string.h> #include <stdlib.h> #include <stdio.h> #include <assert.h> /* * Reverse a string * …

performance algorithm c strings  
asked by true 11 votes
answered by Corbin 22 votes

Generating 1000 random numbers

I have got the following C code and I feel it is crazy stupid and there must be a better way to do this, but just can't think of one and have yet to learn algorithms. /*generates 1000 random numbers, …

optimization c random  
asked by user50585 11 votes
answered by 200_success 14 votes

Greatest hits from previous weeks:

Generating Even Random Numbers

I have this class which is used as part of a game. It needs to generate Random Even values, which is done by generating random numbers until the result is even. Is there a better way to do this? …

java random static  
asked by leonideveloper 21 votes
answered by 200_success 38 votes

Game of Life in Java

I wrote John Conway's Game of Life in Java: class GameOfLife { static int countSurrounding(int[][] board, int a, int b) { int count = 0; int[][] surrounding = {{a - 1, b - 1}, …

java game-of-life  
asked by LazySloth13 4 votes
answered by amon 6 votes

Can you answer these?

Encrypt texts, with saved password using pycrypto

I have the code bellow, which is supposed to be used inside a larger program. Please see notes about the requirements below the code. from __future__ import print_function from Crypto.Cipher import …

python python3 python-2.7 cryptography  
asked by Oz123 1 vote

Kullback-Leibler (KL) distance between inside and outside contour code

I am trying implement the distance measurement between two distributions. The detail is described in here and input image . Let short summarize the idea of the paper: The input image is divided …

image matlab  
asked by user8264 1 vote

iMacros bot for performing refreshes

I'm trying to simplify this code. It seems everything runs as it should; however, when in the refresh loop from iMacro, it seems a little inefficient and can take up to 7 seconds to fully execute (it …

javascript performance  
asked by user3912043 1 vote
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