Code Review Weekly Newsletter

Code Review newsletter

Top new questions this week:

KISS my... unit of work

I've seen many, many UoW+Repository implementations. Whenever one was built on top of Entity Framework, I'd cringe at the added complexity. Sure the complexity buys you (sometimes) full decoupling …

c# design-patterns entity-framework repository  
asked by Mat's Mug 22 votes
answered by Ben Aaronson 14 votes

If she floats then she is not a witch like we thought

Continuing my C++ saga, this is the third project for my CS1 class: Buoyancy is the ability of an object to float. Archimedes' principle states that the buoyant force is equal to the weight of …

c++ beginner c++11 homework  
asked by syb0rg 17 votes
answered by Morwenn 20 votes

Count number of ways to paint a fence with N posts using K colors

A friend sent me this question, and I'd love somebody to review this and give his opinion. Write an algorithm that counts the number of ways you can paint a fence with N posts using K colors …

python algorithm combinatorics  
asked by thomas 14 votes
answered by Gareth Rees 16 votes

C++ function composition

What is a good way to compose std::function objects in C++? I tried the following, and it seems to work well: template<typename ... Fs> struct compose_impl { compose_impl(Fs&& ... …

c++ c++14 higher-order-functions  
asked by davidhigh 12 votes
answered by Morwenn 5 votes

Project Euler #1 in PHP

The code below works & as far as I can tell the result is correct. Would you please review and let me know what I could have done better? I tried to use variables as much as possible, that way it …

php beginner array programming-challenge  
asked by Phrancis 11 votes
answered by Brythan 2 votes

Counting the number of character occurrences

I've written some code that uses a SortedDictionary to count the number of occurrences of a character in a string. How can I improve this code? What should I be doing differently? Any advice at all …

c# beginner  
asked by user9993 11 votes
answered by Anna Lear 8 votes

"Who are you, and where do you live?" — a Q&A exercise

This is my first attempt at a programme. Is it good form? Does it follow best practice? Or am I completely off the mark? #include "stdafx.h" #include <iostream> #include <string> …

c++ beginner validation console io  
asked by Barrie 11 votes
answered by Edward 14 votes

Greatest hits from previous weeks:

Remove-Last-Comma-Problem

is there a more elegant way to solve this problem? List<String> paramList = new ArrayList<String>( ); paramList.add( "param1" ); paramList.add( "param2" ); StringBuilder result = new …

java strings  
asked by Jonas 66 votes
answered by Adeel Zafar Soomro 58 votes

What are the best practices with multithreading in C#?

For a while I have been interested in seeing if some tasks work well when split across multiple threads. On the one project I have been busy with I have been creating a lot of small utility apps, to …

c# .net multithreading  
asked by JonathanPeel 23 votes
answered by Eric Lippert 51 votes

Can you answer these?

Computing values with several large numeric vectors

I have several large numeric vectors (close to 1e6 entries each) and I need to make some computations with their values: iters=100 iters2=100 set.seed(91) sampleSubset<-sample(1:1e6, iters) mR12 …

performance r  
asked by jpcgandre 2 votes

MySQL natural search and like search

I have written two queries for searching, but I want to simplify them as it seems needed. def searching(term: String): List[String] = { DB.withConnection { implicit c => var list = …

mysql mvc scala search  
asked by Govind Singh Nagarkoti 2 votes

printf-like formatting for std::ostream ~ (not exactly) boost::format

cout << format( "%? %?!\n" // Hello world! "%1% %3% :)\n" // Hello again :) "%%05X: %05X\n" // %05X: 01234 "%%g: %g\n" // %g: 3.14159 "%%.3f: …

c++ strings c++11 stream  
asked by firda 5 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